用于增加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)
未完
本文标题:numpy: np.newaxis
本文链接:https://www.haomeiwen.com/subject/hhvhxxtx.html
网友评论