diff --git a/docs/chapter10_natural-language-processing/10.7_sentiment-analysis-rnn.md b/docs/chapter10_natural-language-processing/10.7_sentiment-analysis-rnn.md index ed3eea8998a978dfd8811c6d8073ac89649ee4e4..5a95a90e3f82be4330edeef4b1db5a9044737928 100644 --- a/docs/chapter10_natural-language-processing/10.7_sentiment-analysis-rnn.md +++ b/docs/chapter10_natural-language-processing/10.7_sentiment-analysis-rnn.md @@ -195,15 +195,19 @@ def load_pretrained_embedding(words, pretrained_vocab): idx = pretrained_vocab.stoi[word] embed[i, :] = pretrained_vocab.vectors[idx] except KeyError: - oov_count += 0 + oov_count += 1 if oov_count > 0: - print("There are %d oov words.") + print("There are %d oov words." % oov_count) return embed net.embedding.weight.data.copy_( load_pretrained_embedding(vocab.itos, glove_vocab)) net.embedding.weight.requires_grad = False # 直接加载预训练好的, 所以不需要更新它 ``` +输出: +``` +There are 21202 oov words. +``` ### 10.7.2.2 训练并评价模型