np.newaxis

np.newaxis的作用就是在这一位置增加一个一维,这一位置指的是np.newaxis所在的位置,比较抽象.

In[65]:
l=np.arange(10)
l
Out[65]:
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
In [66]:
l.shape 
Out[66]:
(10,)
In [69]:
l[:,np.newaxis].shape 
Out[69]:
(10, 1)
In[70]:
l[np.newaxis,:].shape
out[70]:
(1,10)

posted on 2019-08-22 08:39  离云1  阅读(204)  评论(0编辑  收藏  举报

导航