这种广播技巧:
>>> x = np.array([1,2,3,4,5])>>> y = np.array([10,20,30,40,50])>>> z = np.linspace(0, 1, 5)>>> z[None, ...] * (y[..., None] - x[..., None]) + ( x[..., None])array([[ 1. , 3.25, 5.5 , 7.75, 10. ], [ 2. , 6.5 , 11. , 15.5 , 20. ], [ 3. , 9.75, 16.5 , 23.25, 30. ], [ 4. , 13. , 22. , 31. , 40. ], [ 5. , 16.25, 27.5 , 38.75, 50. ]])>>>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)