第12章最適化アルゴリズム
12.6.3. Theoretical Analysis12.6.3 理論的な解析
So far the 2D example of seemed rather contrived. We will now see that this is actually quite representative of the types of problem one might encounter, at least in the case of minimizing convex quadratic objective functions.
英語のヒント
ここまで、という2次元の例はかなり作為的に見えた。ここでは、少なくとも凸の2次の目的関数を最小化する場合には、これが実は出会いうる種類の問題をかなりよく代表していることを見る。
12.6.3.1. Quadratic Convex Functions12.6.3.1 2次の凸関数
Consider the function
英語のヒント
次の関数を考えよう。
(12.6.6)
This is a general quadratic function. For positive definite matrices , i.e., for matrices with positive eigenvalues this has a minimizer at with minimum value . Hence we can rewrite as
英語のヒント
これは一般的な2次関数である。正定値行列、つまり固有値が正の行列については、これはに最小化点をもち、最小値はである。したがって、は次のように書き直せる。
(12.6.7)
The gradient is given by . That is, it is given by the distance between and the minimizer, multiplied by . Consequently also the velocity is a linear combination of terms .
英語のヒント
勾配はで与えられる。つまり、それはと最小化点との距離にを掛けたもので与えられる。その結果、速度も項の線形結合になる。
Since is positive definite it can be decomposed into its eigensystem via for an orthogonal (rotation) matrix and a diagonal matrix of positive eigenvalues. This allows us to perform a change of variables from to to obtain a much simplified expression:
英語のヒント
は正定値なので、直交(回転)行列と正の固有値の対角行列によって、と固有系に分解できる。これにより、変数をからへ変換して、ずっと簡単な式が得られる。
(12.6.8)
Here . Since is only an orthogonal matrix this does not perturb the gradients in a meaningful way. Expressed in terms of gradient descent becomes
英語のヒント
ここでである。は直交行列にすぎないので、これは勾配を意味のある形でかき乱さない。で表すと、勾配降下法は次のようになる。
(12.6.9)
The important fact in this expression is that gradient descent does not mix between different eigenspaces. That is, when expressed in terms of the eigensystem of the optimization problem proceeds in a coordinate-wise manner. This also holds for
英語のヒント
この式の重要な事実は、勾配降下法が異なる固有空間のあいだで混ざり合わないことである。つまり、の固有系で表すと、最適化問題は座標ごとに進む。これは次についても成り立つ。
(12.6.10)
In doing this we just proved the following theorem: gradient descent with and without momentum for a convex quadratic function decomposes into coordinate-wise optimization in the direction of the eigenvectors of the quadratic matrix.
英語のヒント
こうして、次の定理を証明したことになる。凸の2次関数に対するモメンタムありとなしの勾配降下法は、2次の行列の固有ベクトルの向きでの座標ごとの最適化に分解される。
12.6.3.2. Scalar Functions12.6.3.2 スカラー関数
Given the above result let’s see what happens when we minimize the function . For gradient descent we have
英語のヒント
上の結果を踏まえて、関数を最小化すると何が起こるかを見よう。勾配降下法では次が成り立つ。
(12.6.11)
Whenever this optimization converges at an exponential rate since after steps we have . This shows how the rate of convergence improves initially as we increase the learning rate until . Beyond that things diverge and for the optimization problem diverges.
英語のヒント
であるときはいつでも、ステップの後にとなるので、この最適化は指数的な速さで収束する。これは、学習率をまで上げていくと、最初は収束の速さがどう改善するかを示している。それを超えると発散に向かい、では最適化問題は発散する。
lambdas = [0.1, 1, 10, 19]
eta = 0.1
d2l.set_figsize((6, 4))
for lam in lambdas:
t = torch.arange(20).detach().numpy()
d2l.plt.plot(t, (1 - eta * lam) ** t, label=f'lambda = {lam:.2f}')
d2l.plt.xlabel('time')
d2l.plt.legend();To analyze convergence in the case of momentum we begin by rewriting the update equations in terms of two scalars: one for and one for velocity . This yields:
英語のヒント
モメンタムの場合の収束を解析するため、まず更新式を二つのスカラーで書き直す。一つはについて、もう一つは速度についてである。すると次が得られる。
(12.6.12)
We used to denote the governing convergence behavior. After steps the initial choice becomes . Hence, it is up to the eigenvalues of to determine the speed of convergence. See the Distill post of Goh (2017) for a great animation and Flammarion and Bach (2015) for a detailed analysis. One can show that velocity converges. This is a larger range of feasible parameters when compared to for gradient descent. It also suggests that in general large values of are desirable. Further details require a fair amount of technical detail and we suggest that the interested reader consult the original publications.
英語のヒント
収束のふるまいを支配するの行列をで表した。ステップの後、最初の選択はになる。したがって、収束の速さを決めるのはの固有値次第である。すばらしいアニメーションについてはGoh (2017)のDistillの記事を、詳しい解析についてはFlammarion and Bach (2015)を参照。なら速度が収束することが示せる。これは、勾配降下法でのと比べて、実行可能なパラメータの範囲が広い。それはまた、一般にの値が大きいのが望ましいことも示唆している。これ以上の詳しいことにはかなりの技術的な詳細が要るので、興味のある読者には元の文献にあたることを勧める。