numpy 矩阵乘法

import numpy as np

a = np.array([
    [1,1],
    [0,1]
])
b = np.arange(4).reshape(2,2)
print(a)
print(b)
print('************************')
# 对应元素相乘
c = a * b
# 矩阵相乘
c_dot = np.dot(a, b)
c_dot_2 = a.dot(b)
print(c)
print('************************')
print(c_dot)
print('************************')
print(c_dot_2)

结果
[[1 1]
[0 1]]
[[0 1]
[2 3]]


[[0 1]
[0 3]]


[[2 4]
[2 3]]


[[2 4]
[2 3]]

你可能感兴趣的:(深度学习)