我正在尝试合并两个嵌入层和一个输入层的输出。代码如下。
maxlen = 200
nFactor = 10
input1 = Input((maxlen, len(chars)))
e1 = Input((maxlen, 1))
e2 = Input((maxlen, 1))
em1 = Embedding(nUser, nFactor + 1, input_length=maxlen)(e1)
em2 = Embedding(nItem, nFactor + 1, input_length=maxlen)(e2)
print(input1._keras_shape)
print(em1._keras_shape)
print(em2._keras_shape)
merged = merge([input1, em1, em2], mode='concat',concat_axis=2)
print(merged._keras_shape)
但是,我在合并步骤遇到了问题。我已经打印了input1,em1和em2的形状,这三个都是3D张量。所以我不确定为什么还有一个加入问题。任何帮助将不胜感激。谢谢!
(None, 200, 98)
(None, 200, 11)
(None, 200, 11)
Traceback (most recent call last):
File "test.py", line 96, in <module>
merged = merge([input1, em1, em2,], mode='concat',concat_axis=2)
File "/home/.../local/lib/python2.7/site-packages/keras/engine/topology.py", line 1680, in merge
name=name)
...
TypeError: Join() can only join tensors with the same number of dimensions.