繁体   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