プリンキピア

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

19.2.4. Bookkeeping the Performance of HPO Algorithms19.2.4 HPOのアルゴリズムの性能を記録する

With any HPO algorithm, we are mostly interested in the best performing configuration (called incumbent) and its validation error after a given wall-clock time. This is why we track runtime per iteration, which includes both the time to run an evaluation (call of objective) and the time to make a decision (call of scheduler.suggest). In the sequel, we will plot cumulative_runtime against incumbent_trajectory in order to visualize the any-time performance of the HPO algorithm defined in terms of scheduler (and searcher). This allows us to quantify not only how well the configuration found by an optimizer works, but also how quickly an optimizer is able to find it.
英語のヒント
どんなHPOのアルゴリズムでも、主に関心があるのは、与えられた実時間の後の、最も性能のよい設定(暫定最良解と呼ばれる)とその検証誤差である。そのため、反復ごとのruntimeを記録する。これには、評価を実行する時間(objectiveの呼び出し)と決定を下す時間(scheduler.suggestの呼び出し)の両方が含まれる。以下では、scheduler(とsearcher)で定義したHPOのアルゴリズムの任意時点での性能を可視化するため、incumbent_trajectoryに対してcumulative_runtimeをプロットする。これによって、最適化手法が見つけた設定がどれだけうまく働くかだけでなく、最適化手法がそれをどれだけ速く見つけられるかも定量化できる。
@d2l.add_to_class(HPOTuner)  #@save
def bookkeeping(self, config: dict, error: float, runtime: float):
    self.records.append({"config": config, "error": error, "runtime": runtime})
    # Check if the last hyperparameter configuration performs better
    # than the incumbent
    if self.incumbent is None or self.incumbent_error > error:
        self.incumbent = config
        self.incumbent_error = error
    # Add current best observed performance to the optimization trajectory
    self.incumbent_trajectory.append(self.incumbent_error)
    # Update runtime
    self.current_runtime += runtime
    self.cumulative_runtime.append(self.current_runtime)