ValueError:维度必须相等,但对于输入形状的"MatMul"(操作:"MatMul"),维度必须相等为 64 和 4:[?,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)

打印(input_encoded_m(显示Tensor("cond_3/Merge:0", shape=(?, 68, 64), dtype=float32),打印(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,这些需要匹配。

您应该查看文档中此处给出的示例。

相关内容

最新更新