求助python两个矩阵元素相乘
import numpy as np #导入numpy库:用于矩阵运算import numpy.matlib
m = 2
n = 3
d = np.array([, ])
b = np.mat()
theta = np.matlib.repmat(b,1,n)
a = np.matlib.repmat(theta,m,1)
print(d * a)
想问一下大佬们,为啥会出现这个错误:ValueError: shapes (2,3) and (2,3) not aligned: 3 (dim 1) != 2 (dim 0) 矩阵相乘
(m*n 矩阵)*(n*p 矩阵)
n 必须相同 import numpy as np
A = np.array([, ])
B = np.array([, , ])
C = np.dot(A, B)
print(C)[
] import numpy as np
A = np.mat([, ])
B = np.mat([, , ])
print(A * B)[[ 5864]
] 你的代码:import numpy as np
import numpy.matlib
m = 2
n = 3
d = np.array([, ])
b = np.mat()
theta = np.matlib.repmat(b, 1, m) # <------ 注意这里
a = np.matlib.repmat(theta, n, 1) # <------ 注意这里
print(d * a)[
[ 8585]]
页:
[1]