![](/img/trans.png)
[英]ValueError: shapes (2,) and (5,) not aligned: 2 (dim 0) != 5 (dim 0)
[英]ValueError: shapes (1,1000) and (1,1000) not aligned: 1000 (dim 1) != 1 (dim 0) When numpy.dot() with two matrices
我試圖使用numpy.dot()將兩個矩陣相乘,它們的尺寸相同。 但是當我嘗試執行此操作時,numpy在標題中給了我錯誤,說它們沒有對齊,這對我來說沒有意義,因為它們的尺寸相同。 誰能告訴我我做錯了什么?
形狀是問題
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.