此功能将数组广播为新维度,它返回原始数组的只读视图,如果新维度不符合NumPy的广播规则,则该函数可能会引发ValueError。
注意-此功能自版本1.10.0 起可用。
该函数采用以下参数。
numpy.broadcast_to(array, shape, subok)
import numpy as np a=np.arange(4).reshape(1,4) print 'The original array:' print a print '\n' print 'After applying the broadcast_to function:' print np.broadcast_to(a,(4,4))
它应该产生以下输出-
[[0 1 2 3] [0 1 2 3] [0 1 2 3] [0 1 2 3]]
参考链接
https://www.learnfk.com/numpy/numpy-broadcast-to.html
标签:numpy,无涯,broadcast,np,print,array,NumPy From: https://blog.51cto.com/u_14033984/7893868