简体   繁体   English

ValueError:形状(1,1000)和(1,1000)不对齐:1000(dim 1)!= 1(dim 0)当numpy.dot()具有两个矩阵时

[英]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.

相关问题 ValueError: 形状 (2,) 和 (5,) 未对齐:2 (dim 0) != 5 (dim 0) - ValueError: shapes (2,) and (5,) not aligned: 2 (dim 0) != 5 (dim 0) ValueError:形状(3,)和(0,)未对齐:3(dim 0)!= 0(dim 0) - ValueError: shapes (3,) and (0,) not aligned: 3 (dim 0) != 0 (dim 0) Python Numpy:ValueError:形状(200,2)和(1,2)不对齐:2(dim 1)!= 1(dim 0) - Python Numpy: ValueError: shapes (200,2) and (1,2) not aligned: 2 (dim 1) != 1 (dim 0) ValueError:形状(1,1)和(4,1)未对齐:1(dim 1)!= 4(dim 0) - ValueError: shapes (1,1) and (4,1) not aligned: 1 (dim 1) != 4 (dim 0) 为什么 numpy.dot() 会抛出 ValueError: shapes not aligned? - Why is numpy.dot() throwing a ValueError: shapes not aligned? ValueError: 形状 (62,6) 和 (5,) 未对齐:6 (dim 1) != 5 (dim 0) - ValueError: shapes (62,6) and (5,) not aligned: 6 (dim 1) != 5 (dim 0) ValueError:形状(2,2)和(4,6)不对齐:2(dim 1)!= 4(dim 0) - ValueError: shapes (2,2) and (4,6) not aligned: 2 (dim 1) != 4 (dim 0) ValueError:形状(4,4)和(3,)不对齐:4(dim 1)!= 3(dim 0) - ValueError: shapes (4,4) and (3,) not aligned: 4 (dim 1) != 3 (dim 0) ValueError:形状(4,1)和(3,1)未对齐:1(dim 1)!= 3(dim 0) - ValueError: shapes (4,1) and (3,1) not aligned: 1 (dim 1) != 3 (dim 0) ValueError:形状 (1,6) 和 (5,5) 未对齐:6 (dim 1) != 5 (dim 0) - ValueError: shapes (1,6) and (5,5) not aligned: 6 (dim 1) != 5 (dim 0)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM