Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Deep learning CNTK提供最终LSTM状态作为另一个LSTM的输入_Deep Learning_Cntk - Fatal编程技术网

Deep learning CNTK提供最终LSTM状态作为另一个LSTM的输入

Deep learning CNTK提供最终LSTM状态作为另一个LSTM的输入,deep-learning,cntk,Deep Learning,Cntk,我正在尝试构建以下体系结构: 嵌入->正向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

我正在尝试构建以下体系结构: 嵌入->正向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#u Output_0',[#],[50])”不支持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)

检查LSTM返回的输出序列和状态。然后,您可以将输出绑定到另一层的输入。

您是否可以确认您的目标是创建序列到序列模型?我这样问是因为这些人通常将自己的输出作为延迟输入。如果这是您想要的,那么请检查Unfollow from()。如果您的第一个e2=。。。是word_embedding=…?我不是在训练一个seq2seq模型。我正在尝试使用LSTM从字符中学习向量表示。将其与预先训练的单词嵌入连接起来,然后将连接的向量输入到另一个LSTM中,后面是一个密集层。是的,关于第一个e2你是正确的,但这不是问题的原因。从我的第二个示例中可以看出,我想弄明白的是,为什么不能将一个LSTM的最终状态作为另一个LSTM的输入。