プリンキピア

第4章分類のための線形ニューラルネットワーク

4.4.7. Exercises4.4.7 練習問題

  1. In this section, we directly implemented the softmax function based on the mathematical definition of the softmax operation. As discussed in Section 4.1 this can cause numerical instabilities.
    英語のヒント
    この節では、ソフトマックス演算の数学的な定義にもとづいて、ソフトマックス関数を直接実装した。4.1節で論じたように、これは数値的な不安定さを引き起こしうる。
    1. Test whether softmax still works correctly if an input has a value of 100.
      英語のヒント
      入力の値が100のとき、softmaxがまだ正しく働くかを試せ。
    2. Test whether softmax still works correctly if the largest of all inputs is smaller than −100?
      英語のヒント
      すべての入力のうち最大のものが−100より小さいとき、softmaxがまだ正しく働くかを試せ。
    3. Implement a fix by looking at the value relative to the largest entry in the argument.
      英語のヒント
      引数の中で最大の成分に対する相対的な値を見ることで、修正を実装せよ。
  2. Implement a cross_entropy function that follows the definition of the cross-entropy loss function ∑iyilog⁡yˆi.
    英語のヒント
    交差エントロピー損失関数の定義∑iyilog⁡yˆiに従うcross_entropy関数を実装せよ。
    1. Try it out in the code example of this section.
      英語のヒント
      この節のコード例で試してみよ。
    2. Why do you think it runs more slowly?
      英語のヒント
      それがより遅く動くのはなぜだと思うか。
    3. Should you use it? When would it make sense to?
      英語のヒント
      それを使うべきか。使うのが理にかなうのはどんなときか。
    4. What do you need to be careful of? Hint: consider the domain of the logarithm.
      英語のヒント
      何に注意する必要があるか。ヒント:対数の定義域を考えよ。
  3. Is it always a good idea to return the most likely label? For example, would you do this for medical diagnosis? How would you try to address this?
    英語のヒント
    最も可能性の高いラベルを返すのは、いつでもよい考えか。たとえば、医療の診断でこれをするだろうか。これにどう対処しようとするか。
  4. Assume that we want to use softmax regression to predict the next word based on some features. What are some problems that might arise from a large vocabulary?
    英語のヒント
    何らかの特徴量にもとづいて、ソフトマックス回帰で次の単語を予測したいとする。語彙が大きいことから生じうる問題には、どんなものがあるか。
  5. Experiment with the hyperparameters of the code in this section. In particular:
    英語のヒント
    この節のコードのハイパーパラメータで実験せよ。特に次を試せ。
    1. Plot how the validation loss changes as you change the learning rate.
      英語のヒント
      学習率を変えるにつれて検証損失がどう変わるかをプロットせよ。
    2. Do the validation and training loss change as you change the minibatch size? How large or small do you need to go before you see an effect?
      英語のヒント
      ミニバッチの大きさを変えると、検証損失と訓練損失は変わるか。効果が見えるまでには、どれだけ大きく、あるいは小さくする必要があるか。