我正在尝试构建以下架构: 嵌入 - >转发LSTM - >向后LSTM - > Concat最终状态 - > Concat外嵌 - > LSTM
我的代码如下所示:
i = Input(features)
e = Embedding(25)(i)
# Forward and backward LSTM
h_f = Recurrence(LSTM(25), go_backwards=False)(e)
h_b = Recurrence(LSTM(25), go_backwards=True)(e)
# Get the final states and splice
f = sequence.last(h_f)
b = sequence.first(h_b)
e1 = splice(f, b)
# Get the other embedding and concat
i2 = Input(100)
e2 = Embedding(100)(i2)
e2 = sequence.first(word_embedding)
e3 = splice(e1, e2)
# Input concatenated embedding to new LSTM
r = Recurrence(LSTM(50))(e3)
当我这样做时,我收到以下错误: 输入操作数'输出('Block1994_Output_0',[#],[50])'用#dynamic axes!= 2(1个顺序轴和1个批次轴)不支持。
如果我没有得到我的第一个双向LSTM的最终状态,那么它工作正常,但这不是我想要的。
我还可以通过这个简单的例子重现错误:
i = Input(features)
e = Embedding(25)(i)
h_f = Fold(LSTM(25), go_backwards=False)(e)
s = Recurrence(LSTM(25))(h_f)