向量化矩阵计算公式:
"""
@Title: matrix_calculating
@Time: 2024/3/6
@Author: Michael Jie
"""
import numpy as np
w = np.array([[1, 2]])
x = np.array([[1, 1], [2, 3], [4, 5]])
b = 1
# w * x + b
print(w * x + b)
"""
[[ 2 3]
[ 3 7]
[ 5 11]]
"""
# y = w * x + b
print(np.dot(x, w.T) + b)
"""
[[ 4]
[ 9]
[15]]
"""
# y = w * x + b
print(np.sum(w * x, axis=1).reshape(-1, 1) + 1)
"""
[[ 4]
[ 9]
[15]]
"""