簡體   English   中英

ValueError:尺寸必須相等,但輸入形狀為[?,64],[4 ,?]的'MatMul'(op:'MatMul')的尺寸必須為64和4

[英]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_mquestion_encoded 怎么了 ?

我不確定您實際輸入的數量是哪個維度,但是第一個維度必須相同。

但是例如,您需要具有形狀:

(68, 64, 4)(68, 4, 64)

要么

(64, 68, 4)(64, 4, 68)

要么

(4, 68, 64)(4, 64, 68)等。

但是您有輸入684 ,這些需要匹配。

您應該在docs中查看此處給出的示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM