numpy函数linspace() newaxis()

格式:
numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)

功能:指定的间隔返回均匀间隔的数字
返回:num均匀分布的样本,在[start, stop]。这个区间的端点可以任意的被排除在外。

x= np.linspace(0,1,4)

x
Out[88]: array([ 0.1,  0.3., 0.2.,  0.4])
x= np.linspace(0,3,4)[:,np.newaxis ]

x
Out[90]: 
array([[ 0.],
       [ 1.],
       [ 2.],
       [ 3.]])
x= np.linspace(0,3,4)[np.newaxis ,:]
x
Out[92]: array([[ 0.,  1.,  2.,  3.]])

 

posted @ 2019-08-08 16:13  也许明天、  阅读(341)  评论(0)    收藏  举报