![](/img/trans.png)
[英]Dimensions must be equal, but are 1 and 128 for 'sampled_softmax_loss/MatMul' (op: 'MatMul') with input shapes: [128,1], [64,128]
[英]ValueError: Dimensions must be equal, but are 64 and 4 for 'MatMul' (op: 'MatMul') with input shapes: [?,64], [4,?]
我有個錯誤
ValueError: Dimensions must be equal, but are 64 and 4 for 'MatMul' (op: 'MatMul') with input shapes: [?,64], [4,?].
我寫了代碼
from keras import backend as K
print(input_encoded_m)
print(question_encoded)
match = K.dot(input_encoded_m, question_encoded)
print(input_encoded_m)顯示Tensor("cond_3/Merge:0", shape=(?, 68, 64), dtype=float32)
和print(question_encoded)顯示Tensor("cond_5/Merge:0", shape=(?, 4, 64), dtype=float32)
。我認為點方法不適用於計算具有不同等級的矩陣,所以我重寫
from keras import backend as K
match = K.get_value(input_encoded_m * question_encoded)
但是會發生此錯誤:
ValueError: Dimensions must be equal, but are 68 and 4 for 'mul' (op: 'Mul') with input shapes: [?,68,64], [?,4,64]
如何計算input_encoded_m
和question_encoded
? 怎么了 ?
我不確定您實際輸入的數量是哪個維度,但是第一個維度必須相同。
但是例如,您需要具有形狀:
(68, 64, 4)
和(68, 4, 64)
要么
(64, 68, 4)
和(64, 4, 68)
要么
(4, 68, 64)
和(4, 64, 68)
等。
但是您有輸入68
和4
,這些需要匹配。
您應該在docs中查看此處給出的示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.