第19章ハイパーパラメータ最適化
19.2. Hyperparameter Optimization API19.2 ハイパーパラメータ最適化のAPI
Before we dive into the methodology, we will first discuss a basic code structure that allows us to efficiently implement various HPO algorithms. In general, all HPO algorithms considered here need to implement two decision making primitives, searching and scheduling. First, they need to sample new hyperparameter configurations, which often involves some kind of search over the configuration space. Second, for each configuration, an HPO algorithm needs to schedule its evaluation and decide how many resources to allocate for it. Once we start to evaluate a configuration, we will refer to it as a trial. We map these decisions to two classes,
HPOSearcher and HPOScheduler. On top of that, we also provide a HPOTuner class that executes the optimization process.英語のヒント
方法論に深く入る前に、まず、さまざまなHPOのアルゴリズムを効率よく実装できるようにする基本的なコードの構造を論じる。一般に、ここで考えるHPOのアルゴリズムはすべて、探索とスケジューリングという二つの意思決定の基本要素を実装する必要がある。第一に、新しいハイパーパラメータの設定を抜き出す必要があり、これにはしばしば設定空間の上での何らかの探索がともなう。第二に、HPOのアルゴリズムは、各設定について、その評価をスケジュールし、それにどれだけの資源を割り当てるかを決める必要がある。ある設定の評価を始めたら、それを試行と呼ぶ。これらの決定を二つのクラス、
HPOSearcherとHPOSchedulerに対応させる。それに加えて、最適化の過程を実行するHPOTunerクラスも用意する。This concept of scheduler and searcher is also implemented in popular HPO libraries, such as Syne Tune (Salinas et al., 2022), Ray Tune (Liaw et al., 2018) or Optuna (Akiba et al., 2019).
英語のヒント
スケジューラとサーチャーというこの概念は、Syne Tune(Salinas et al., 2022)、Ray Tune(Liaw et al., 2018)、Optuna(Akiba et al., 2019)のような、よく使われるHPOのライブラリにも実装されている。
import time
from scipy import stats
from d2l import torch as d2l