プリンキピア

第19章ハイパーパラメータ最適化

19.1. What Is Hyperparameter Optimization?19.1 ハイパーパラメータ最適化とは何か

As we have seen in the previous chapters, deep neural networks come with a large number of parameters or weights that are learned during training. On top of these, every neural network has additional hyperparameters that need to be configured by the user. For example, to ensure that stochastic gradient descent converges to a local optimum of the training loss (see Section 12), we have to adjust the learning rate and batch size. To avoid overfitting on training datasets, we might have to set regularization parameters, such as weight decay (see Section 3.7) or dropout (see Section 5.6). We can define the capacity and inductive bias of the model by setting the number of layers and number of units or filters per layer (i.e., the effective number of weights).
英語のヒント
前の章で見てきたように、深層ニューラルネットワークには、訓練のあいだに学習される多数のパラメータ、つまり重みがある。それに加えて、どのニューラルネットワークにも、利用者が設定する必要のある追加のハイパーパラメータがある。たとえば、確率的勾配降下法が訓練損失の局所的な最適値に収束することを確かにするには(第12章を参照)、学習率とバッチの大きさを調整しなければならない。訓練データセットへの過学習を避けるには、重み減衰(3.7節を参照)やドロップアウト(5.6節を参照)のような正則化パラメータを設定しなければならないかもしれない。層の数と、層ごとのユニットやフィルタの数(つまり実質的な重みの数)を設定することで、モデルの容量と帰納バイアスを定められる。
Unfortunately, we cannot simply adjust these hyperparameters by minimizing the training loss, because this would lead to overfitting on the training data. For example, setting regularization parameters, such as dropout or weight decay to zero leads to a small training loss, but might hurt the generalization performance.
英語のヒント
残念ながら、訓練損失を最小化することでこれらのハイパーパラメータを単純に調整することはできない。それでは訓練データへの過学習につながるからである。たとえば、ドロップアウトや重み減衰のような正則化パラメータを0に設定すると、訓練損失は小さくなるが、汎化性能を損なうかもしれない。
Fig. 19.1.1図19.1.1
Typical workflow in machine learning that consists of training the model multiple times with different hyperparameters.
英語のヒント
異なるハイパーパラメータでモデルを何度も訓練することからなる、機械学習の典型的な作業の流れ。
Without a different form of automation, hyperparameters have to be set manually in a trial-and-error fashion, in what amounts to a time-consuming and difficult part of machine learning workflows. For example, consider training a ResNet (see Section 8.6) on CIFAR-10, which requires more than 2 hours on an Amazon Elastic Cloud Compute (EC2) g4dn.xlarge instance. Even just trying ten hyperparameter configurations in sequence, this would already take us roughly one day. To make matters worse, hyperparameters are usually not directly transferable across architectures and datasets (Bardenet et al., 2013, Feurer et al., 2022, Wistuba et al., 2018), and need to be re-optimized for every new task. Also, for most hyperparameters, there are no rule-of-thumbs, and expert knowledge is required to find sensible values.
英語のヒント
別の形の自動化がなければ、ハイパーパラメータは試行錯誤で手作業で設定しなければならず、それは機械学習の作業の流れの中で、時間がかかり難しい部分になる。たとえば、CIFAR-10でResNet(8.6節を参照)を訓練することを考えよう。これには、Amazon Elastic Cloud Compute(EC2)のg4dn.xlargeインスタンスで2時間以上かかる。10個のハイパーパラメータの設定を順に試すだけでも、すでにおよそ1日かかることになる。さらに悪いことに、ハイパーパラメータはふつう、アーキテクチャやデータセットをまたいでそのまま移せず(Bardenet et al., 2013、Feurer et al., 2022、Wistuba et al., 2018)、新しいタスクごとに最適化し直す必要がある。また、たいていのハイパーパラメータには経験則がなく、妥当な値を見つけるには専門家の知識が必要である。
Hyperparameter optimization (HPO) algorithms are designed to tackle this problem in a principled and automated fashion (Feurer and Hutter, 2018), by framing it as a global optimization problem. The default objective is the error on a hold-out validation dataset, but could in principle be any other business metric. It can be combined with or constrained by secondary objectives, such as training time, inference time, or model complexity.
英語のヒント
ハイパーパラメータ最適化(HPO)のアルゴリズムは、この問題を大域的な最適化問題として定式化することで、原理にもとづき自動化されたやり方でこの問題に取り組むよう設計されている(Feurer and Hutter, 2018)。既定の目的関数は取り置いた検証データセットでの誤差だが、原理的にはほかのどんなビジネスの指標でもよい。それは、訓練時間、推論時間、モデルの複雑さのような副次的な目的関数と組み合わせたり、それらによって制約したりできる。
Recently, hyperparameter optimization has been extended to neural architecture search (NAS) (Elsken et al., 2018, Wistuba et al., 2019), where the goal is to find entirely new neural network architectures. Compared to classical HPO, NAS is even more expensive in terms of computation and requires additional efforts to remain feasible in practice. Both, HPO and NAS can be considered as sub-fields of AutoML (Hutter et al., 2019), which aims to automate the entire ML pipeline.
英語のヒント
最近、ハイパーパラメータ最適化は、まったく新しいニューラルネットワークのアーキテクチャを見つけることを目標とするニューラルアーキテクチャ探索(NAS)(Elsken et al., 2018、Wistuba et al., 2019)にまで拡張されている。古典的なHPOと比べて、NASは計算の点でさらに高くつき、実際に実行可能であり続けるには追加の工夫が必要である。HPOとNASはどちらも、機械学習のパイプライン全体の自動化を目指すAutoML(Hutter et al., 2019)の下位分野とみなせる。
In this section we will introduce HPO and show how we can automatically find the best hyperparameters of the logistic regression example introduced in Section 4.5.
英語のヒント
この節では、HPOを紹介し、4.5節で紹介したロジスティック回帰の例の最良のハイパーパラメータを自動的に見つける方法を示す。