0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Tensorflow】パンケーキの焼き方で学ぶHyperband

Posted at

Hyperbandとは

Hyperband は「Successive Halving」を拡張したハイパーパラメータ探索アルゴリズムで、限られた計算リソースで効率よく最適な設定を見つけるために以下の数式を用います。

  • $R$:最大リソース量(例:最大エポック数や焼成時間)

  • $\eta$:削減率(次のステップに残す割合の逆数)

  • $s_{max}$:ブランケット数

    $s_{max} = \lfloor \log_{\eta} R \rfloor$

  • 各ブランケット $s$ の初期設定

    $n_s = \left\lceil \frac{s_{max} + 1}{s + 1} \eta^{s}\right\rceil,\quad r_s = \frac{R}{\eta^{s}}$

    • $n_s$:試す候補(パンケーキ枚数)
    • $r_s$:最初に割り当てるリソース(焼成時間)

パンケーキの焼き方で例える

  1. たくさんのレシピを一口サイズで試作
    • 例:27枚の一口パンケーキを各1分ずつ焼いて味見
  2. 上位1/η(例:1/3)のレシピだけ残す
    • 27枚→上位9枚を「本番サイズ(3分)」で再度試作
  3. さらに上位1/ηを絞り込む
    • 9枚→上位3枚を「フルサイズ(9分)」で再試作
  4. 最終評価
    • 残った3枚から最もおいしい1枚を「じっくり(27分)」焼いて決定

数式がパンケーキの焼き方のどこに該当するのか

  • $R=27$:最もじっくり焼くときの時間(分)

  • $\eta=3$:毎ステップで上位1/3を残す

  • $s_{max}=3$:ステップ数(一口→本番→フル→最終)

  • $n_s$、$r_s$ の対応

    $s$ $n_s$(枚) $r_s$(分) パンケーキの焼き方
    0 $\lceil4/1 \cdot 3^0\rceil=4$ $27/1=27$ 4枚を27分じっくり味見
    1 $\lceil4/2 \cdot 3^1\rceil=6$ $27/3=9$ 6枚を9分でざっくり評価
    2 $\lceil4/3 \cdot 3^2\rceil=12$ $27/9=3$ 12枚を3分で一口サイズ味見
    3 $\lceil4/4 \cdot 3^3\rceil=27$ $27/27=1$ 27枚を1分で超高速評価(省リソース)

まとめ

  • Hyperband の肝:多くを少しずつ試し、良い候補にリソースを集中する
  • 数式
    • $s_{max}=\lfloor\log_{\eta}R\rfloor$
    • $n_s=\lceil\frac{s_{max}+1}{s+1}\eta^s\rceil,;r_s=\frac{R}{\eta^s}$
  • パンケーキ例
    1. 一口サイズ→上位1/η
    2. 本番サイズ→再抽出
    3. フルサイズ→最終決定
  • メリット:無駄な学習を減らし、短時間で最適設定を発見できる!
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?