expand_dims函数

 

>>> x = np.array([1,2])
>>> x.shape
(2,)
>>> y = np.expand_dims(x, axis=0)
>>> y
array([[1, 2]])
>>> y.shape
(1, 2)

 

>>> x = np.array([1,2])
>>> x.shape
(2,)
>>> y = np.expand_dims(x, axis=1) 
>>> y
array([[1],
       [2]])
>>> y.shape
(2, 1)

 

posted @ 2017-03-01 23:07  有梦就要去实现他  阅读(2430)  评论(0)    收藏  举报