プリンキピア

第16章自然言語処理:応用

16.2.5. Exercises16.2.5 練習問題

  1. Increase the number of epochs. Can you improve the training and testing accuracies? How about tuning other hyperparameters?
    英語のヒント
    エポック数を増やせ。訓練とテストの正解率を改善できるか。ほかのハイパーパラメータを調整するとどうか。
  2. Use larger pretrained word vectors, such as 300-dimensional GloVe embeddings. Does it improve classification accuracy?
    英語のヒント
    300次元のGloVeの埋め込みのような、もっと大きな事前学習した単語ベクトルを使え。分類の正解率は改善するか。
  3. Can we improve the classification accuracy by using the spaCy tokenization? You need to install spaCy (pip install spacy) and install the English package (python -m spacy download en). In the code, first, import spaCy (import spacy). Then, load the spaCy English package (spacy_en = spacy.load('en')). Finally, define the function def tokenizer(text): return [tok.text for tok in spacy_en.tokenizer(text)] and replace the original tokenizer function. Note the different forms of phrase tokens in GloVe and spaCy. For example, the phrase token “new york” takes the form of “new-york” in GloVe and the form of “new york” after the spaCy tokenization.
    英語のヒント
    spaCyのトークン化を使うと、分類の正解率を改善できるか。spaCyをインストールし(pip install spacy)、英語のパッケージをインストールする(python -m spacy download en)必要がある。コードでは、まずspaCyをインポートする(import spacy)。それから、spaCyの英語のパッケージを読み込む(spacy_en = spacy.load('en'))。最後に、関数def tokenizer(text): return [tok.text for tok in spacy_en.tokenizer(text)]を定義して、元のtokenizer関数を置き換える。GloVeとspaCyでは句のトークンの形が異なることに注意しよう。たとえば、句のトークン「new york」は、GloVeでは「new-york」の形をとり、spaCyのトークン化の後では「new york」の形をとる。