第19章ハイパーパラメータ最適化
19.1.4. Exercises19.1.4 練習問題
- In this chapter, we optimize the validation error of a model after training on a disjoint training set. For simplicity, our code uses
Trainer.val_dataloader, which maps to a loader aroundFashionMNIST.val.英語のヒント
この章では、互いに素な訓練集合で訓練した後のモデルの検証誤差を最適化する。簡単にするため、コードではTrainer.val_dataloaderを使っており、これはFashionMNIST.valを包むローダーに対応する。- Convince yourself (by looking at the code) that this means we use the original FashionMNIST training set (60000 examples) for training, and the original test set (10000 examples) for validation.
英語のヒント
これは、元のFashionMNISTの訓練集合(60000事例)を訓練に、元のテスト集合(10000事例)を検証に使うことを意味すると、(コードを見て)納得せよ。 - Why could this practice be problematic? Hint: Re-read Section 3.6, especially about model selection.
英語のヒント
このやり方はなぜ問題になりうるのか。ヒント:3.6節を、特にモデル選択について読み直せ。 - What should we have done instead?
英語のヒント
代わりに何をすべきだったか。
- We stated above that hyperparameter optimization by gradient descent is very hard to do. Consider a small problem, such as training a two-layer perceptron on the FashionMNIST dataset (Section 5.2) with a batch size of 256. We would like to tune the learning rate of SGD in order to minimize a validation metric after one epoch of training.
英語のヒント
上で、勾配降下法によるハイパーパラメータ最適化はとても難しいと述べた。FashionMNISTのデータセット(5.2節)で、バッチの大きさを256として2層のパーセプトロンを訓練するような小さな問題を考えよう。訓練の1エポックの後の検証指標を最小化するように、SGDの学習率を調整したい。- Why cannot we use validation error for this purpose? What metric on the validation set would you use?
英語のヒント
この目的に検証誤差を使えないのはなぜか。検証集合でのどんな指標を使うか。 - Sketch (roughly) the computational graph of the validation metric after training for one epoch. You may assume that initial weights and hyperparameters (such as learning rate) are input nodes to this graph. Hint: Re-read about computational graphs in Section 5.3.
英語のヒント
1エポック訓練した後の検証指標の計算グラフを(大まかに)描け。初期の重みとハイパーパラメータ(学習率など)は、このグラフへの入力ノードだと仮定してよい。ヒント:5.3節の計算グラフについて読み直せ。 - Give a rough estimate of the number of floating point values you need to store during a forward pass on this graph. Hint: FashionMNIST has 60000 cases. Assume the required memory is dominated by the activations after each layer, and look up the layer widths in Section 5.2.
英語のヒント
このグラフでの順伝播のあいだに保存する必要がある浮動小数点数の値の数を、大まかに見積もれ。ヒント:FashionMNISTには60000の事例がある。必要なメモリは各層の後の活性で占められると仮定し、5.2節で層の幅を調べよ。 - Apart from the sheer amount of compute and storage required, what other issues would gradient-based hyperparameter optimization run into? Hint: Re-read about vanishing and exploding gradients in Section 5.4.
英語のヒント
必要な計算と記憶領域の量の多さそのもののほかに、勾配にもとづくハイパーパラメータ最適化はどんな問題にぶつかるだろうか。ヒント:5.4節の勾配消失と勾配爆発について読み直せ。 - Advanced: Read (Maclaurin et al., 2015) for an elegant (yet still somewhat unpractical) approach to gradient-based HPO.
英語のヒント
発展:勾配にもとづくHPOへの、洗練された(しかしまだいくぶん実用的でない)やり方について、(Maclaurin et al., 2015)を読め。
- Grid search is another HPO baseline, where we define an equi-spaced grid for each hyperparameter, then iterate over the (combinatorial) Cartesian product in order to suggest configurations.
英語のヒント
グリッド探索はもう一つのHPOのベースラインで、各ハイパーパラメータに等間隔のグリッドを定義し、それから(組み合わせ的な)直積を順にたどって設定を提案する。- We stated above that random search can be much more efficient than grid search for HPO on a sizable number of hyperparameters, if the criterion most strongly depends on a small subset of the hyperparameters. Why is this? Hint: Read (Bergstra et al., 2011).
英語のヒント
上で、ハイパーパラメータの数がかなり多いHPOでは、基準がハイパーパラメータの小さな部分集合に最も強く依存するなら、ランダム探索はグリッド探索よりはるかに効率的になりうると述べた。それはなぜか。ヒント:(Bergstra et al., 2011)を読め。