每天一点点,记录工作中实操可行
lst1 = np.array([10,20,30,40])
lst2 = np.array([4,3,2,1])
print(np.dot(lst1.reshape([2,2]),lst2.reshape([2,2])))
结果:
[[ 80 50]
[200 130]]
怎么回事???这个结果是怎么计算出来的???
lst1.reshape([2,2])
lst2.reshape([2,2])
将列表 lst1 和列表lst2 分别reshape 2行2列的结果是
array([[10, 20],
[30, 40]])
array([[4, 3],
[2, 1]])
np.dot:
所得到的数组中的每个元素为,第一个矩阵中与该元素行号相同的元素与第二个矩阵与该元素列号相同的元素,两两相乘后再求和;
这句话有点晦涩
10*4+20*2 = 80
10*3+20*1 = 50
30*4+40*2 = 200
30*3+40*1 = 130
这样,是不是可以好理解一点