第19章ハイパーパラメータ最適化
19.2.2. Scheduler19.2.2 スケジューラ
Beyond sampling configurations for new trials, we also need to decide when and for how long to run a trial. In practice, all these decisions are done by the
HPOScheduler, which delegates the choice of new configurations to a HPOSearcher. The suggest method is called whenever some resource for training becomes available. Apart from invoking sample_configuration of a searcher, it may also decide upon parameters like max_epochs (i.e., how long to train the model for). The update method is called whenever a trial returns a new observation.英語のヒント
新しい試行のための設定を抜き出すほかに、試行をいつ、どれだけの長さ実行するかも決める必要がある。実際には、これらの決定はすべて
HPOSchedulerが行い、新しい設定の選択はHPOSearcherに任せる。suggestメソッドは、訓練のための資源が使えるようになるたびに呼ばれる。サーチャーのsample_configurationを呼び出すほかに、max_epochsのようなパラメータ(つまりモデルをどれだけの長さ訓練するか)を決めることもある。updateメソッドは、試行が新しい観測を返すたびに呼ばれる。class HPOScheduler(d2l.HyperParameters): #@save
def suggest(self) -> dict:
raise NotImplementedError
def update(self, config: dict, error: float, info=None):
raise NotImplementedErrorTo implement random search, but also other HPO algorithms, we only need a basic scheduler that schedules a new configuration every time new resources become available.
英語のヒント
ランダム探索だけでなくほかのHPOのアルゴリズムも実装するには、新しい資源が使えるようになるたびに新しい設定をスケジュールする基本的なスケジューラだけがあればよい。
class BasicScheduler(HPOScheduler): #@save
def __init__(self, searcher: HPOSearcher):
self.save_hyperparameters()
def suggest(self) -> dict:
return self.searcher.sample_configuration()
def update(self, config: dict, error: float, info=None):
self.searcher.update(config, error, additional_info=info)