プリンキピア

第12章最適化アルゴリズム

12.4.2. Dynamic Learning Rate12.4.2 動的な学習率

Replacing η with a time-dependent learning rate η(t) adds to the complexity of controlling convergence of an optimization algorithm. In particular, we need to figure out how rapidly η should decay. If it is too quick, we will stop optimizing prematurely. If we decrease it too slowly, we waste too much time on optimization. The following are a few basic strategies that are used in adjusting η over time (we will discuss more advanced strategies later):
英語のヒント
ηを時間に依存する学習率η(t)に置き換えると、最適化アルゴリズムの収束を制御する複雑さが増す。特に、ηをどれくらい速く減衰させるべきかを見極める必要がある。速すぎると、最適化を早まって止めてしまう。遅すぎると、最適化に時間を無駄に使いすぎる。以下は、ηを時間とともに調整するのに使われる基本的な戦略のいくつかである(もっと高度な戦略は後で論じる)。
η(t)=ηi if ti≤t≤ti+1piecewise constantη(t)=η0⋅e−λtexponential decayη(t)=η0⋅(βt+1)−αpolynomial decay(12.4.5)
In the first piecewise constant scenario we decrease the learning rate, e.g., whenever progress in optimization stalls. This is a common strategy for training deep networks. Alternatively we could decrease it much more aggressively by an exponential decay. Unfortunately this often leads to premature stopping before the algorithm has converged. A popular choice is polynomial decay with α=0.5. In the case of convex optimization there are a number of proofs that show that this rate is well behaved.
英語のヒント
最初の区分的に一定な場合では、たとえば最適化の進み具合が止まるたびに学習率を下げる。これは深いネットワークを訓練するときによく使われる戦略である。別のやり方として、指数的な減衰によって、もっとずっと積極的に下げることもできる。残念ながら、これはしばしば、アルゴリズムが収束する前に早まって止まることにつながる。人気のある選択は、α=0.5とした多項式の減衰である。凸最適化の場合には、この速さが行儀がよいことを示す証明がいくつもある。
Let’s see what the exponential decay looks like in practice.
英語のヒント
指数的な減衰が実際にどう見えるかを見よう。
def exponential_lr():
    # Global variable that is defined outside this function and updated inside
    global t
    t += 1
    return math.exp(-0.1 * t)

t = 1
lr = exponential_lr
d2l.show_trace_2d(f, d2l.train_2d(sgd, steps=1000, f_grad=f_grad))
epoch 1000, x1: -0.758829, x2: -0.115584
As expected, the variance in the parameters is significantly reduced. However, this comes at the expense of failing to converge to the optimal solution 𝐱=(0,0). Even after 1000 iteration steps are we are still very far away from the optimal solution. Indeed, the algorithm fails to converge at all. On the other hand, if we use a polynomial decay where the learning rate decays with the inverse square root of the number of steps, convergence gets better after only 50 steps.
英語のヒント
予想どおり、パラメータの分散は大きく減った。しかし、その代償として、最適解𝐱=(0,0)に収束できていない。1000回の反復ステップの後でさえ、まだ最適解からとても遠い。実際、このアルゴリズムはまったく収束しない。一方、学習率がステップ数の平方根の逆数で減衰する多項式の減衰を使うと、わずか50ステップの後で収束がよくなる。
def polynomial_lr():
    # Global variable that is defined outside this function and updated inside
    global t
    t += 1
    return (1 + 0.1 * t) ** (-0.5)

t = 1
lr = polynomial_lr
d2l.show_trace_2d(f, d2l.train_2d(sgd, steps=50, f_grad=f_grad))
epoch 50, x1: 0.144834, x2: 0.041688
There exist many more choices for how to set the learning rate. For instance, we could start with a small rate, then rapidly ramp up and then decrease it again, albeit more slowly. We could even alternate between smaller and larger learning rates. There exists a large variety of such schedules. For now let’s focus on learning rate schedules for which a comprehensive theoretical analysis is possible, i.e., on learning rates in a convex setting. For general nonconvex problems it is very difficult to obtain meaningful convergence guarantees, since in general minimizing nonlinear nonconvex problems is NP hard. For a survey see e.g., the excellent lecture notes of Tibshirani 2015.
英語のヒント
学習率の設定の仕方には、ほかにもずっと多くの選択肢がある。たとえば、小さな学習率から始め、すばやく上げ、それから、もっとゆっくりとではあるが、また下げることもできる。小さい学習率と大きい学習率を交互に使うことさえできる。そうしたスケジュールには多種多様なものがある。いまは、包括的な理論的解析ができる学習率のスケジュール、つまり凸の設定での学習率に焦点を当てよう。一般の非凸の問題では、意味のある収束の保証を得るのはとても難しい。一般に、非線形の非凸の問題を最小化することはNP困難だからである。概観には、たとえばTibshirani 2015のすばらしい講義ノートを参照。