numpy数据相减,a和b两者shape要一样,然后是对应的位置相减。要不然,a的shape可以是(1,m),注意m要等于b的列数。
import numpy as np a = [ [0, 1, 2] ] a = np.array(a) b = [ [1.0,1.1, 3], [1.0,1.0, 3], [0,0, 3], [0,0.1, 3] ] b = np.array(b) result = a - b print(result)
原文地址:https://www.cnblogs.com/jim7086/p/9320494.html
时间: 2024-11-02 02:24:21