亲爱的chainer社区
我对seq2seq
official example(英法翻译)中NStepLSTM
的逻辑用法感到费解。在
据我所知,def __call__(self, xs, ys):
xs = [x[::-1] for x in xs] #Reverse x
是英语短语,ys
是法语短语。你为什么把英语短语颠倒过来?
如何训练网络?将xs
和{eys
将潜在表示放入解码器中。但是eys
是法语短语的连续表示,在测试阶段解码器无法知道生成的法语短语,对吗?你如何运用你的人际网络?在
hx, cx, _ = self.the encoder(None, None, exs)
_, _, os = self.decoder(hx, cx, eys)
ys_in = [F.concat([eos, y], axis=0) for y in ys]
为什么我们把end of sequence
放在开头?
ys = self.xp.full(batch, EOS, 'i')
在def translate
中,我们把end of sequence
的数组放入解码器,为什么?在如果我不想翻译句子,而是想建立一个自动编码器,将短语映射到潜在空间,我该怎么办?在
谢谢你的问题。在
请参阅以下seq2seq原稿。 他们建议:
Note that the LSTM reads the input sentence in reverse, because doing so introduces many short term dependencies in the data that make the optimization problem much easier.
(摘要)
we found that reversing the order of the words in all source sentences (but not target sentences) improved the LSTM’s performance markedly
https://papers.nips.cc/paper/5346-sequence-to-sequence-learning-with-neural-networks.pdf我认为官方的示例代码也与上面的文章中的输入语句相反。在
在是的。这个代码是在训练时间使用的,所以我们知道目标句子(黄金单词)。在
在测试时,您应该使用
^{pr2}$def translate(self, xs, max_length=100):
。 该方法可用于从源句xs
预测句子。在对于每个循环,用源句子向量和前一个单词
ys
预测一个单词。在我认为这一部分应该是:
ys_in = [F.concat([bos, y], axis=0) for y in ys]
(句首) 官方代码对和都使用eos
。在当你想建立一个自动编码器
xs = [x[::-1] for x in xs]
ys_in = [F.concat([eos, y], axis=0) for y in ys]
中使用bos
,而不是eos
是否使用
eos
而不是bos
,两者都很好。 您只需删除自动编码器的这行xs = [x[::-1] for x in xs]
。在如果要使用
bos
,则应修改如下:如果你还有其他问题,请再问我一次。在
相关问题 更多 >
编程相关推荐