multiply对应位置相乘 与 dot矩阵乘

区别

# -*- coding: utf-8 -*-
import numpy as np
a = np.array([[1,2],
             [3,4]])

b= np.arange(4).reshape((2,2))

c = a*b
c_dot = np.dot(a,b)
c_mul = np.multiply(a,b)

print('a:',a)
print('b:',b)

print(c)
print(c_dot)
print(c_mul)

 结果是

a: [[1 2]
 [3 4]]
b: [[0 1]
 [2 3]]
[[ 0  2]
 [ 6 12]]
[[ 4  7]
 [ 8 15]]
[[ 0  2]
 [ 6 12]]

猜你喜欢

转载自www.cnblogs.com/clemente/p/10585037.html