プリンキピア

第10章現代のリカレントニューラルネットワーク

10.7.6. Training10.7.6 訓練

Now we can create and train an RNN encoder–decoder model for sequence-to-sequence learning on the machine translation dataset.
英語のヒント
これで、機械翻訳のデータセットで、系列から系列への学習のためのRNNのエンコーダ・デコーダモデルを作り、訓練できる。
data = d2l.MTFraEng(batch_size=128)
embed_size, num_hiddens, num_layers, dropout = 256, 256, 2, 0.2
encoder = Seq2SeqEncoder(
    len(data.src_vocab), embed_size, num_hiddens, num_layers, dropout)
decoder = Seq2SeqDecoder(
    len(data.tgt_vocab), embed_size, num_hiddens, num_layers, dropout)
model = Seq2Seq(encoder, decoder, tgt_pad=data.tgt_vocab['<pad>'],
                lr=0.005)
trainer = d2l.Trainer(max_epochs=30, gradient_clip_val=1, num_gpus=1)
trainer.fit(model, data)