why do we need np.squeeze()?

后端 未结 4 660
北恋
北恋 2021-01-30 12:56

Very often, arrays are squeezed with np.squeeze(). In the documentation, it says

Remove single-dimensional entries from the shape of a.

4条回答
  •  青春惊慌失措
    2021-01-30 13:45

    This helps you get rid of useless one dimension arrays like using [7,8,9] instead of [[[7,8,9]]] or [[1,2,3],[4,5,6]] instead of [[[[1,2,3],[4,5,6]]]]. Check this link from tutorials point for example.

提交回复
热议问题