numpy: np.newaxis
2017-05-15 本文已影响0人
贝伟强
用于增加array的dimension
比如:
1D 会变成 2D,2D会变成3D……
x1 = np.array([1, 2, 3])
np.shape(x1) # (3,)
x2 = x1[:, np.newaxis]
np.shape(x2) # (3, 1)
x3 = x1[np.newaxis, :]
np.shape(x3) # (1, 3)
未完
用于增加array的dimension
比如:
1D 会变成 2D,2D会变成3D……
x1 = np.array([1, 2, 3])
np.shape(x1) # (3,)
x2 = x1[:, np.newaxis]
np.shape(x2) # (3, 1)
x3 = x1[np.newaxis, :]
np.shape(x3) # (1, 3)
未完