def build_decoder(opt, embeddings): """ Various decoder dispatcher function. Args: opt: the option in current environment. embeddings (Embeddings): vocab embeddings for this decoder. """ return TransformerDecoder(opt.dec_layers, opt.dec_rnn_size, opt.heads, opt.transformer_ff, opt.dropout, embeddings)
def build_decoder(opt, embeddings, pos = None): """ Various decoder dispatcher function. Args: opt: the option in current environment. embeddings (Embeddings): vocab embeddings for this decoder. """ # 根据transformer论文,整个decoder层由dec_layers=6层堆叠而成,d_model = dec_rnn_size = 512, # multi-head attention中 h = heads = 8, feed-forward层大小为transformer_ff=2048 return TransformerDecoder(opt.dec_layers, opt.dec_rnn_size, opt.heads, opt.transformer_ff, opt.dropout, embeddings, pos)