プリンキピア

第22章付録:深層学習のための数学

22.4.3. A Note on Mathematical Optimization22.4.3 数理最適化についての注意

Throughout this book, we focus squarely on numerical optimization techniques for the practical reason that all functions we encounter in the deep learning setting are too complex to minimize explicitly.
英語のヒント
本書を通じて、数値的な最適化の技法にはっきりと焦点を当てる。深層学習の設定で出会う関数はどれも、明示的に最小化するには複雑すぎるという実際的な理由からである。
However, it is a useful exercise to consider what the geometric understanding we obtained above tells us about optimizing functions directly.
英語のヒント
しかし、上で得た幾何学的な理解が、関数を直接最適化することについて何を教えてくれるかを考えるのは、役に立つ練習である。
Suppose that we wish to find the value of 𝐱0 which minimizes some function L(𝐱). Let’s suppose that moreover someone gives us a value and tells us that it is the value that minimizes L. Is there anything we can check to see if their answer is even plausible?
英語のヒント
ある関数L(𝐱)を最小にする𝐱0の値を見つけたいとする。さらに、だれかがある値を示して、それがLを最小にする値だと言ったとしよう。その答えがそもそももっともらしいかどうかを確かめるために、チェックできることは何かあるだろうか。
Again consider (22.4.5):
英語のヒント
もう一度、式(22.4.5)を考えよう。
L(𝐱0+𝝐)≈L(𝐱0)+𝝐⋅∇𝐱L(𝐱0).(22.4.11)
If the gradient is not zero, we know that we can take a step in the direction −ϵ∇𝐱L(𝐱0) to find a value of L that is smaller. Thus, if we truly are at a minimum, this cannot be the case! We can conclude that if 𝐱0 is a minimum, then ∇𝐱L(𝐱0)=0. We call points with ∇𝐱L(𝐱0)=0 critical points.
英語のヒント
勾配が0でなければ、−ϵ∇𝐱L(𝐱0)の方向に一歩進んで、より小さいLの値を見つけられることがわかる。したがって、本当に最小値にいるなら、そうはなりえない。𝐱0が最小値なら∇𝐱L(𝐱0)=0であると結論できる。∇𝐱L(𝐱0)=0となる点を臨界点と呼ぶ。
This is nice, because in some rare settings, we can explicitly find all the points where the gradient is zero, and find the one with the smallest value.
英語のヒント
これはよいことである。というのも、まれな設定では、勾配が0になる点をすべて明示的に見つけ、その中で値が最も小さいものを見つけられるからである。
For a concrete example, consider the function
英語のヒント
具体的な例として、次の関数を考えよう。
f(x)=3x4−4x3−12x2.(22.4.12)
This function has derivative
英語のヒント
この関数の導関数は次のとおりである。
dfdx=12x3−12x2−24x=12x(x−2)(x+1).(22.4.13)
The only possible location of minima are at x=−1,0,2, where the function takes the values −5,0,−32 respectively, and thus we can conclude that we minimize our function when x=2. A quick plot confirms this.
英語のヒント
最小値がありうる場所はx=−1,0,2だけであり、そこで関数はそれぞれ値−5,0,−32をとるので、x=2のときに関数が最小になると結論できる。手早くプロットすると、これが確かめられる。
x = torch.arange(-2, 3, 0.01)
f = (3 * x**4) - (4 * x**3) - (12 * x**2)

d2l.plot(x, f, 'x', 'f(x)')
This highlights an important fact to know when working either theoretically or numerically: the only possible points where we can minimize (or maximize) a function will have gradient equal to zero, however, not every point with gradient zero is the true global minimum (or maximum).
英語のヒント
これは、理論的に扱うときも数値的に扱うときも知っておくべき重要な事実を浮き彫りにする。関数を最小化(または最大化)できる点は勾配が0でなければならないが、勾配が0の点がすべて本当の大域的な最小値(または最大値)だとはかぎらない。