1、numpy 乘法运算中 "*" 是数组元素逐个计算具体代码如下:
a = np.array([[1,2],[3,4]]) b = np.array([[1,2],[3,4]]) print(a) print(b) print(a*b) """ [[1 2] [3 4]] [[1 2] [3 4]] [[ 1 4] [ 9 16]] """
2、numpy乘法运算中dot是按照矩阵乘法的规则来运算的具体实现代码如下:
a = np.array([[1,2,3],[4,5,6]]) b = np.arange(7,13).reshape(3,2) print(a) print(b) print(np.dot(a,b)) print(np.dot(a,b).shape) """ [[1 2 3] [4 5 6]] [[ 7 8] [ 9 10] [11 12]] [[ 58 64] [139 154]] (2, 2) """