第22章付録:深層学習のための数学
22.4.4. Multivariate Chain Rule22.4.4 多変数の連鎖律
Let’s suppose that we have a function of four variables (, and ) which we can make by composing many terms:
英語のヒント
四つの変数(、)の関数があり、それを多くの項を合成して作れるとしよう。
(22.4.14)
Such chains of equations are common when working with neural networks, so trying to understand how to compute gradients of such functions is key. We can start to see visual hints of this connection in Fig. 22.4.1 if we take a look at what variables directly relate to one another.
英語のヒント
ニューラルネットワークを扱うときにはこのような方程式の連鎖はよくあるので、こうした関数の勾配をどう計算するかを理解しようとすることが鍵になる。どの変数が互いに直接関係しているかを見ると、図22.4.1でこのつながりの視覚的な手がかりが見え始める。
Fig. 22.4.1図22.4.1
The function relations above where nodes represent values and edges show functional dependence.
英語のヒント
上の関数の関係。ノードは値を表し、エッジは関数としての依存関係を示す。
Nothing stops us from just composing everything from (22.4.14) and writing out that
英語のヒント
式(22.4.14)のすべてを単純に合成して、次のように書き出すのを妨げるものは何もない。
(22.4.15)
We may then take the derivative by just using single variable derivatives, but if we did that we would quickly find ourself swamped with terms, many of which are repeats! Indeed, one can see that, for instance:
英語のヒント
それから1変数の導関数だけを使って導関数をとれるが、そうすると、すぐに項に埋もれてしまい、その多くは繰り返しである。実際、たとえば次のようになることがわかる。
(22.4.16)
If we then also wanted to compute , we would end up with a similar equation again with many repeated terms, and many shared repeated terms between the two derivatives. This represents a massive quantity of wasted work, and if we needed to compute derivatives this way, the whole deep learning revolution would have stalled out before it began!
英語のヒント
さらにも計算したいとすると、多くの繰り返しの項をもつ似た式がまた出てきて、二つの導関数の間でも繰り返しの項が多く共有される。これは膨大な量の無駄な作業であり、もし導関数をこのように計算する必要があったら、深層学習の革命全体が始まる前に行き詰まっていただろう。
Let’s break up the problem. We will start by trying to understand how changes when we change , essentially assuming that , and all do not exist. We will reason as we did back when we worked with the gradient for the first time. Let’s take and add a small amount to it.
英語のヒント
問題を分解しよう。まず、を変えたときにがどう変わるかを、本質的にとがどれも存在しないと仮定して理解しようとすることから始める。初めて勾配を扱ったときと同じように推論する。をとり、それに小さな量を加えよう。
(22.4.17)
The first line follows from the definition of partial derivative, and the second follows from the definition of gradient. It is notationally burdensome to track exactly where we evaluate every derivative, as in the expression , so we often abbreviate this to the much more memorable
英語のヒント
1行目は偏導関数の定義から、2行目は勾配の定義から従う。式のように、各導関数をどこで評価するかを正確に追いかけるのは記法の上で負担が大きいので、これをずっと覚えやすい次の形に略すことが多い。
(22.4.18)
It is useful to think about the meaning of the process. We are trying to understand how a function of the form changes its value with a change in . There are two pathways this can occur: there is the pathway where and where . We can compute both of these contributions via the chain rule: and respectively, and added up.
英語のヒント
この過程の意味を考えると役に立つ。という形の関数が、の変化によってその値をどう変えるかを理解しようとしている。これが起きる経路は二つある。という経路とという経路である。これら二つの寄与はどちらも連鎖律で計算でき、それぞれととなり、それらを足し合わせる。
Imagine we have a different network of functions where the functions on the right depend on those that are connected to on the left as is shown in Fig. 22.4.2.
英語のヒント
図22.4.2に示すように、右側の関数が左側でつながっている関数に依存する、別の関数のネットワークがあると想像しよう。
Fig. 22.4.2図22.4.2
Another more subtle example of the chain rule.
英語のヒント
連鎖律のもう一つの、もっと微妙な例。
To compute something like , we need to sum over all (in this case ) paths from to giving
英語のヒント
のようなものを計算するには、からへのすべての(この場合は本の)経路について和をとる必要があり、次のようになる。
(22.4.19)
Understanding the chain rule in this way will pay great dividends when trying to understand how gradients flow through networks, and why various architectural choices like those in LSTMs (Section 10.1) or residual layers (Section 8.6) can help shape the learning process by controlling gradient flow.