From e90d41bdc614df4e521f891ddefc09f77b94e401 Mon Sep 17 00:00:00 2001 From: Aston Zhang Date: Fri, 23 Oct 2020 09:54:05 +0000 Subject: [PATCH] lib sync --- d2l/mxnet.py | 6 +++--- d2l/tensorflow.py | 4 ++-- d2l/torch.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/d2l/mxnet.py b/d2l/mxnet.py index 4687ca6c0c..865b403b17 100644 --- a/d2l/mxnet.py +++ b/d2l/mxnet.py @@ -840,9 +840,9 @@ def load_data_nmt(batch_size, num_steps, num_examples=600): """Return the iterator and the vocabularies of the translation dataset.""" text = preprocess_nmt(read_data_nmt()) source, target = tokenize_nmt(text, num_examples) - src_vocab = d2l.Vocab(source, min_freq=2, + src_vocab = d2l.Vocab(source, min_freq=2, reserved_tokens=['', '', '']) - tgt_vocab = d2l.Vocab(target, min_freq=2, + tgt_vocab = d2l.Vocab(target, min_freq=2, reserved_tokens=['', '', '']) src_array, src_valid_len = build_array_nmt(source, src_vocab, num_steps) tgt_array, tgt_valid_len = build_array_nmt(target, tgt_vocab, num_steps) @@ -976,7 +976,7 @@ def predict_s2s_ch9(model, src_sentence, src_vocab, tgt_vocab, num_steps, # of the decoder at the next time step dec_X = Y.argmax(axis=2) pred = dec_X.squeeze(axis=0).astype('int32').item() - # Once the end-of-sequence token is predicted, the generation of + # Once the end-of-sequence token is predicted, the generation of # the output sequence is complete if pred == tgt_vocab['']: break diff --git a/d2l/tensorflow.py b/d2l/tensorflow.py index 3a60c9c8be..50dc347aac 100644 --- a/d2l/tensorflow.py +++ b/d2l/tensorflow.py @@ -843,9 +843,9 @@ def load_data_nmt(batch_size, num_steps, num_examples=600): """Return the iterator and the vocabularies of the translation dataset.""" text = preprocess_nmt(read_data_nmt()) source, target = tokenize_nmt(text, num_examples) - src_vocab = d2l.Vocab(source, min_freq=2, + src_vocab = d2l.Vocab(source, min_freq=2, reserved_tokens=['', '', '']) - tgt_vocab = d2l.Vocab(target, min_freq=2, + tgt_vocab = d2l.Vocab(target, min_freq=2, reserved_tokens=['', '', '']) src_array, src_valid_len = build_array_nmt(source, src_vocab, num_steps) tgt_array, tgt_valid_len = build_array_nmt(target, tgt_vocab, num_steps) diff --git a/d2l/torch.py b/d2l/torch.py index e1fc14d764..5f149db482 100644 --- a/d2l/torch.py +++ b/d2l/torch.py @@ -903,9 +903,9 @@ def load_data_nmt(batch_size, num_steps, num_examples=600): """Return the iterator and the vocabularies of the translation dataset.""" text = preprocess_nmt(read_data_nmt()) source, target = tokenize_nmt(text, num_examples) - src_vocab = d2l.Vocab(source, min_freq=2, + src_vocab = d2l.Vocab(source, min_freq=2, reserved_tokens=['', '', '']) - tgt_vocab = d2l.Vocab(target, min_freq=2, + tgt_vocab = d2l.Vocab(target, min_freq=2, reserved_tokens=['', '', '']) src_array, src_valid_len = build_array_nmt(source, src_vocab, num_steps) tgt_array, tgt_valid_len = build_array_nmt(target, tgt_vocab, num_steps) @@ -1062,7 +1062,7 @@ def predict_s2s_ch9(model, src_sentence, src_vocab, tgt_vocab, num_steps, # of the decoder at the next time step dec_X = Y.argmax(dim=2) pred = dec_X.squeeze(dim=0).type(torch.int32).item() - # Once the end-of-sequence token is predicted, the generation of + # Once the end-of-sequence token is predicted, the generation of # the output sequence is complete if pred == tgt_vocab['']: break