1. 矩阵乘法
import numpy as np
x_true = np.arange(start=0, stop=4, step=1, dtype=float)
x_true = np.reshape(x_true, newshape=[2, 2])
print(x_true)
y_true = np.dot(x_true, x_true)
print(y_true)
输出
[[ 0. 1.]
[ 2. 3.]]
[[ 2. 3.]
[ 6. 11.]]
2. 对应元素乘法
import numpy as np
x_true = np.arange(start=0, stop=4, step=1, dtype=float)
x_true = np.reshape(x_true, newshape=[2, 2])
print(x_true)
y_true = x_true*x_true
print(y_true)
输出
[[ 0. 1.]
[ 2. 3.]]
[[ 0. 1.]
[ 4. 9.]]