![](/img/trans.png)
[英]ValueError: Dimensions must be equal, but are 784 and 500 for 'Mul' (op: 'Mul') with input shapes: [?,784], [784,500]
[英]python numpy ValueError:shapes (171,) and (784,500) not aligned: 171
我有數據向量(1個列),我正在使用
def propup(self, vis):
pre_sigmoid_activation = numpy.dot(vis, self.W) + self.hbias
return sigmoid(pre_sigmoid_activation)
但我得到錯誤
ValueError:形狀(171,)和(784,500)不對齊:171(dim 0)!= 784(dim 0)
一個矩陣和矢量之間的點積被定義為如此 。
這意味着矩陣的寬度和向量的高度應相同。
在您的情況下, ves.shape = [,171]
是矢量的高度,但是self.W.shape = [784, 500]
表示矩陣self.W
的寬度是784。為了使numpy.dot
工作正確地,您需要確保ves.shape = [x, 784]
,其中x是某個整數。
沒有更多的代碼,我只能猜測您正在嘗試訓練神經網絡來解決MNIST問題(784維度非常具體)。 因此,請確保將正確的向量發送到propup()
。 無論如何,這里有一些有關矩陣乘法的重要資料:矩陣乘法: https : //www.mathsisfun.com/algebra/matrix-multiplying.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.