[英]ValueError: shapes (1,1000) and (1,1000) not aligned: 1000 (dim 1) != 1 (dim 0) When numpy.dot() with two matrices
I am trying to multiply two matrices using numpy.dot() and they are the same dimensions. 我试图使用numpy.dot()将两个矩阵相乘,它们的尺寸相同。 But when i try to do it numpy gives me the error in the title saying that they are not aligned which doesnt make sense to me because they are the same dimensions.
但是当我尝试执行此操作时,numpy在标题中给了我错误,说它们没有对齐,这对我来说没有意义,因为它们的尺寸相同。 Could anyone explain to me what I am doing wrong?
谁能告诉我我做错了什么?
The shape is the issue 形状是问题
a = np.arange(3).reshape(1,3)
b = np.arange(3,6).reshape(1,3)
np.dot(a, b)
Traceback (most recent call last):
File "<ipython-input-88-c9cc415545b4>", line 1, in <module>
np.dot(a, b)
ValueError: shapes (1,3) and (1,3) not aligned: 3 (dim 1) != 1 (dim 0)
c = b.reshape(3,1)
np.dot(a,c)
array([[14]])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.