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.]])

浙公网安备 33010602011771号