- numpy的升维
将(2,)变成(2,1)
a = np.array([1,2])
b = np.expand_dims(a, axis=1)
- numpy的降维
将(2,1)变成(2,)
a = np.array([[1],[2]])
b = np.squeeze(a)
a = np.array([1,2])
b = np.expand_dims(a, axis=1)
a = np.array([[1],[2]])
b = np.squeeze(a)
本文标题:numpy的升维和降维
本文链接:https://www.haomeiwen.com/subject/kxlwuqtx.html
网友评论