【发布时间】:2020-04-17 02:21:21
【问题描述】:
大家好,我最近开始使用 PyTorch 进行需要编码器-解码器框架的研究。 PyTorch关于这方面的教程很精彩,但是有个小问题:在没有teacher forcing的情况下训练decoder时,也就是说将当前时间步的预测作为下一个时间步的输入,预测应该是detached吗?
在this PyTorch tutorial 中,使用了detach (decoder_input = topi.squeeze().detach() # detach from history as input
),但在this one (top1 = output.max(1)[1]; output = (trg[t] if teacher_force else top1)) 中却不是这样。
两个教程都是基于 RNN 的,所以我不确定基于 Transformer 的架构。如果有人能指出哪个是更好的做法,将不胜感激:)。
【问题讨论】: