numpy里的两个array,怎么进行矩阵乘法?
1个回答
numpy.dot或者numpy.matmul都可以
>>> a
array([[1, 2],
[3, 4]])
>>> b
array([[1, 2, 3],
[1, 2, 1]])
# numpy.dot
>>> np.dot(a, b)
array([[ 3, 6, 5],
[ 7, 14, 13]])
# numpy.matmul
>>> np.matmul(a, b)
array([[ 3, 6, 5],
[ 7, 14, 13]])
thanks!
-
魏哲
2017-11-08 23:12