第2章準備
2.4.1. Derivatives and Differentiation2.4.1 導関数と微分
Put simply, a derivative is the rate of change in a function with respect to changes in its arguments. Derivatives can tell us how rapidly a loss function would increase or decrease were we to increase or decrease each parameter by an infinitesimally small amount. Formally, for functions , that map from scalars to scalars, the derivative of at a point is defined as
英語のヒント
簡単に言えば、導関数とは、引数の変化に対する関数の変化率である。導関数は、各パラメータを無限に小さな量だけ増やしたり減らしたりしたら、損失関数がどれほど速く増えたり減ったりするかを教えてくれる。形式的には、スカラーからスカラーへ写す関数について、点でのの導関数は次のように定義される。
(2.4.1)
This term on the right hand side is called a limit and it tells us what happens to the value of an expression as a specified variable approaches a particular value. This limit tells us what the ratio between a perturbation and the change in the function value converges to as we shrink its size to zero.
英語のヒント
右辺のこの項は極限と呼ばれ、指定した変数がある値に近づくとき、式の値に何が起きるかを教えてくれる。この極限は、摂動と関数の値の変化との比が、その大きさをゼロに縮めていくときに何に収束するかを教えてくれる。
When exists, is said to be differentiable at ; and when exists for all on a set, e.g., the interval , we say that is differentiable on this set. Not all functions are differentiable, including many that we wish to optimize, such as accuracy and the area under the receiving operating characteristic (AUC). However, because computing the derivative of the loss is a crucial step in nearly all algorithms for training deep neural networks, we often optimize a differentiable surrogate instead.
英語のヒント
が存在するとき、はで微分可能であるという。また、ある集合、たとえば区間上のすべてのについてが存在するとき、はこの集合上で微分可能であるという。すべての関数が微分可能なわけではない。最適化したい関数の多く、たとえば正解率や受信者動作特性曲線の下の面積(AUC)も微分可能ではない。しかし、損失の導関数を計算することは、深いニューラルネットワークを訓練するほぼすべてのアルゴリズムで決定的な段階なので、代わりに微分可能な代理を最適化することが多い。
We can interpret the derivative as the instantaneous rate of change of with respect to . Let’s develop some intuition with an example. Define .
英語のヒント
導関数は、に対するの瞬間的な変化率と解釈できる。例で直観を養おう。と定義する。
def f(x):
return 3 * x ** 2 - 4 * xSetting , we see that approaches as approaches . While this experiment lacks the rigor of a mathematical proof, we can quickly see that indeed .
英語のヒント
とすると、がに近づくにつれてがに近づくことがわかる。この実験には数学的な証明の厳密さはないが、確かにであることがすぐにわかる。
for h in 10.0**np.arange(-1, -6, -1):
print(f'h={h:.5f}, numerical limit={(f(1+h)-f(1))/h:.5f}')h=0.10000, numerical limit=2.30000
h=0.01000, numerical limit=2.03000
h=0.00100, numerical limit=2.00300
h=0.00010, numerical limit=2.00030
h=0.00001, numerical limit=2.00003There are several equivalent notational conventions for derivatives. Given , the following expressions are equivalent:
英語のヒント
導関数には、同値な記法の約束がいくつかある。が与えられたとき、次の式はすべて同値である。
(2.4.2)
where the symbols and are differentiation operators. Below, we present the derivatives of some common functions:
英語のヒント
ここで記号とは微分演算子である。下に、よく使う関数の導関数を示す。
(2.4.3)
Functions composed from differentiable functions are often themselves differentiable. The following rules come in handy for working with compositions of any differentiable functions and , and constant .
英語のヒント
微分可能な関数から合成された関数は、それ自体も微分可能であることが多い。任意の微分可能な関数と、定数の合成を扱うには、次の規則が役に立つ。
(2.4.4)
Using this, we can apply the rules to find the derivative of via
英語のヒント
これを使って、規則を当てはめ、の導関数を次のように求められる。
(2.4.5)
Plugging in shows that, indeed, the derivative equals at this location. Note that derivatives tell us the slope of a function at a particular location.
英語のヒント
を代入すると、確かにこの位置で導関数がに等しいことがわかる。導関数は、ある位置での関数の傾きを教えてくれることに注意してほしい。