プリンキピア

第5章多層パーセプトロン

5.1.1. Hidden Layers5.1.1 隠れ層

We described affine transformations in Section 3.1.1.1 as linear transformations with added bias. To begin, recall the model architecture corresponding to our softmax regression example, illustrated in Fig. 4.1.1. This model maps inputs directly to outputs via a single affine transformation, followed by a softmax operation. If our labels truly were related to the input data by a simple affine transformation, then this approach would be sufficient. However, linearity (in affine transformations) is a strong assumption.
英語のヒント
3.1.1.1節では、アフィン変換を、バイアスを加えた線形変換として説明した。まず、図4.1.1に図示した、ソフトマックス回帰の例に対応するモデルの構造を思い出してほしい。このモデルは、一つのアフィン変換と、それに続くソフトマックス演算によって、入力を出力へ直接写す。ラベルが本当に単純なアフィン変換で入力データと関係しているなら、この手法で十分だろう。しかし、(アフィン変換における)線形性は強い仮定である。

5.1.1.1. Limitations of Linear Models5.1.1.1 線形モデルの限界

For example, linearity implies the weaker assumption of monotonicity, i.e., that any increase in our feature must either always cause an increase in our model’s output (if the corresponding weight is positive), or always cause a decrease in our model’s output (if the corresponding weight is negative). Sometimes that makes sense. For example, if we were trying to predict whether an individual will repay a loan, we might reasonably assume that all other things being equal, an applicant with a higher income would always be more likely to repay than one with a lower income. While monotonic, this relationship likely is not linearly associated with the probability of repayment. An increase in income from $0 to $50,000 likely corresponds to a bigger increase in likelihood of repayment than an increase from $1 million to $1.05 million. One way to handle this might be to postprocess our outcome such that linearity becomes more plausible, by using the logistic map (and thus the logarithm of the probability of outcome).
英語のヒント
たとえば、線形性は、より弱い仮定である単調性を含意する。つまり、特徴量が増えれば、モデルの出力は必ずいつも増える(対応する重みが正の場合)か、いつも減る(対応する重みが負の場合)かのどちらかでなければならない。それが理にかなうこともある。たとえば、個人がローンを返済するかどうかを予測しようとしているなら、ほかの条件がすべて同じなら、収入の高い申込者は収入の低い申込者よりもいつも返済する可能性が高い、と仮定するのは妥当だろう。この関係は単調ではあっても、返済の確率と線形に結びついてはいないだろう。収入が0ドルから5万ドルに増えることは、100万ドルから105万ドルに増えることよりも、返済の見込みの大きな増加に対応するだろう。これに対処する一つの方法は、ロジスティック写像(したがって結果の確率の対数)を使って、線形性がよりもっともらしくなるように結果を後処理することかもしれない。
Note that we can easily come up with examples that violate monotonicity. Say for example that we want to predict health as a function of body temperature. For individuals with a normal body temperature above 37°C (98.6°F), higher temperatures indicate greater risk. However, if the body temperatures drops below 37°C, lower temperatures indicate greater risk! Again, we might resolve the problem with some clever preprocessing, such as using the distance from 37°C as a feature.
英語のヒント
単調性を破る例は簡単に思いつくことに注意してほしい。たとえば、体温の関数として健康状態を予測したいとしよう。平熱の37°C(98.6°F)を上回る人では、体温が高いほど危険が大きいことを示す。しかし、体温が37°Cを下回ると、体温が低いほど危険が大きいことを示す!この場合も、37°Cからの距離を特徴量として使うといった、気の利いた前処理で問題を解決できるかもしれない。
But what about classifying images of cats and dogs? Should increasing the intensity of the pixel at location (13, 17) always increase (or always decrease) the likelihood that the image depicts a dog? Reliance on a linear model corresponds to the implicit assumption that the only requirement for differentiating cats and dogs is to assess the brightness of individual pixels. This approach is doomed to fail in a world where inverting an image preserves the category.
英語のヒント
では、猫と犬の画像を分類する場合はどうか。位置(13, 17)の画素の明るさを増やすと、その画像が犬を写している見込みがいつも増える(あるいはいつも減る)はずだろうか。線形モデルに頼ることは、猫と犬を見分けるのに必要なのは個々の画素の明るさを評価することだけだ、という暗黙の仮定に対応する。画像を反転してもカテゴリーが変わらない世界では、この手法は失敗する運命にある。
And yet despite the apparent absurdity of linearity here, as compared with our previous examples, it is less obvious that we could address the problem with a simple preprocessing fix. That is, because the significance of any pixel depends in complex ways on its context (the values of the surrounding pixels). While there might exist a representation of our data that would take into account the relevant interactions among our features, on top of which a linear model would be suitable, we simply do not know how to calculate it by hand. With deep neural networks, we used observational data to jointly learn both a representation via hidden layers and a linear predictor that acts upon that representation.
英語のヒント
それでも、ここでの線形性の明らかなばかばかしさにもかかわらず、前の例と比べると、単純な前処理の工夫で問題に対処できるかどうかははっきりしない。というのも、どの画素の意味も、その文脈(周りの画素の値)に複雑なしかたで依存するからである。特徴量のあいだの関係する相互作用を考慮に入れ、その上でなら線形モデルが適するような、データの表現が存在するかもしれないが、それを手で計算する方法はとにかくわからない。深いニューラルネットワークでは、観測データを使って、隠れ層による表現と、その表現に作用する線形の予測器の両方を一緒に学習した。
This problem of nonlinearity has been studied for at least a century (Fisher, 1925). For instance, decision trees in their most basic form use a sequence of binary decisions to decide upon class membership (Quinlan, 1993). Likewise, kernel methods have been used for many decades to model nonlinear dependencies (Aronszajn, 1950). This has found its way into nonparametric spline models (Wahba, 1990) and kernel methods (Schölkopf and Smola, 2002). It is also something that the brain solves quite naturally. After all, neurons feed into other neurons which, in turn, feed into other neurons again (Ramón y Cajal and Azoulay, 1894). Consequently we have a sequence of relatively simple transformations.
英語のヒント
この非線形性の問題は、少なくとも1世紀にわたって研究されてきた(Fisher, 1925)。たとえば、最も基本的な形の決定木は、二値の判断を順に重ねて、どのクラスに属するかを決める(Quinlan, 1993)。同様に、カーネル法は何十年も前から非線形の依存関係をモデル化するのに使われてきた(Aronszajn, 1950)。これは、ノンパラメトリックなスプラインモデル(Wahba, 1990)やカーネル法(Schölkopf and Smola, 2002)にも取り入れられた。それはまた、脳がごく自然に解いていることでもある。結局のところ、ニューロンはほかのニューロンに信号を送り、そのニューロンがまたほかのニューロンに送るのである(Ramón y Cajal and Azoulay, 1894)。その結果、比較的単純な変換が順に重なることになる。

5.1.1.2. Incorporating Hidden Layers5.1.1.2 隠れ層を組み込む

We can overcome the limitations of linear models by incorporating one or more hidden layers. The easiest way to do this is to stack many fully connected layers on top of one another. Each layer feeds into the layer above it, until we generate outputs. We can think of the first L−1 layers as our representation and the final layer as our linear predictor. This architecture is commonly called a multilayer perceptron, often abbreviated as MLP (Fig. 5.1.1).
英語のヒント
一つ以上の隠れ層を組み込めば、線形モデルの限界を乗り越えられる。そのいちばん簡単な方法は、全結合層をたくさん積み重ねることである。各層はその上の層に出力を渡し、それを出力が生成されるまで続ける。最初のL−1層を表現、最後の層を線形の予測器とみなせる。この構造は一般に多層パーセプトロンと呼ばれ、しばしばMLPと略される(図5.1.1)。
Fig. 5.1.1図5.1.1
An MLP with a hidden layer of five hidden units.
英語のヒント
5個の隠れユニットからなる隠れ層をもつMLP。
This MLP has four inputs, three outputs, and its hidden layer contains five hidden units. Since the input layer does not involve any calculations, producing outputs with this network requires implementing the computations for both the hidden and output layers; thus, the number of layers in this MLP is two. Note that both layers are fully connected. Every input influences every neuron in the hidden layer, and each of these in turn influences every neuron in the output layer. Alas, we are not quite done yet.
英語のヒント
このMLPには入力が4個、出力が3個あり、隠れ層には隠れユニットが5個ある。入力層は何の計算も伴わないので、このネットワークで出力を生成するには、隠れ層と出力層の両方の計算を実装する必要がある。したがって、このMLPの層の数は2である。どちらの層も全結合であることに注意してほしい。どの入力も隠れ層のすべてのニューロンに影響し、隠れ層の各ニューロンは今度は出力層のすべてのニューロンに影響する。しかし残念ながら、まだ完全には終わっていない。

5.1.1.3. From Linear to Nonlinear5.1.1.3 線形から非線形へ

As before, we denote by the matrix 𝐗∈ℝn×d a minibatch of n examples where each example has d inputs (features). For a one-hidden-layer MLP whose hidden layer has h hidden units, we denote by 𝐇∈ℝn×h the outputs of the hidden layer, which are hidden representations. Since the hidden and output layers are both fully connected, we have hidden-layer weights 𝐖(1)∈ℝd×h and biases 𝐛(1)∈ℝ1×h and output-layer weights 𝐖(2)∈ℝh×q and biases 𝐛(2)∈ℝ1×q. This allows us to calculate the outputs 𝐎∈ℝn×q of the one-hidden-layer MLP as follows:
英語のヒント
前と同じく、各事例がd個の入力(特徴量)をもつn個の事例のミニバッチを、行列𝐗∈ℝn×dで表す。隠れ層がh個の隠れユニットをもつ、隠れ層が一つのMLPについて、隠れ層の出力を𝐇∈ℝn×hで表す。これは隠れ表現である。隠れ層と出力層はどちらも全結合なので、隠れ層の重み𝐖(1)∈ℝd×hとバイアス𝐛(1)∈ℝ1×h、出力層の重み𝐖(2)∈ℝh×qとバイアス𝐛(2)∈ℝ1×qがある。これにより、隠れ層が一つのMLPの出力𝐎∈ℝn×qを次のように計算できる。
𝐇=𝐗𝐖(1)+𝐛(1),𝐎=𝐇𝐖(2)+𝐛(2).(5.1.1)
Note that after adding the hidden layer, our model now requires us to track and update additional sets of parameters. So what have we gained in exchange? You might be surprised to find out that—in the model defined above—we gain nothing for our troubles! The reason is plain. The hidden units above are given by an affine function of the inputs, and the outputs (pre-softmax) are just an affine function of the hidden units. An affine function of an affine function is itself an affine function. Moreover, our linear model was already capable of representing any affine function.
英語のヒント
隠れ層を加えたので、モデルは追加のパラメータの組を追跡し更新することを求めるようになったことに注意してほしい。では、その引き換えに何を得たのだろうか。驚くかもしれないが、上で定義したモデルでは、苦労に見合うものを何も得ていない!理由は明白である。上の隠れユニットは入力のアフィン関数で与えられ、出力(ソフトマックスの前)は隠れユニットのアフィン関数にすぎない。アフィン関数のアフィン関数は、それ自体アフィン関数である。そのうえ、線形モデルはもともと、どんなアフィン関数でも表せた。
To see this formally we can just collapse out the hidden layer in the above definition, yielding an equivalent single-layer model with parameters 𝐖=𝐖(1)𝐖(2) and 𝐛=𝐛(1)𝐖(2)+𝐛(2):
英語のヒント
これを形式的に確かめるには、上の定義から隠れ層を畳み込んで消せばよい。すると、パラメータ𝐖=𝐖(1)𝐖(2)と𝐛=𝐛(1)𝐖(2)+𝐛(2)をもつ、同等の単層モデルが得られる。
𝐎=(𝐗𝐖(1)+𝐛(1))𝐖(2)+𝐛(2)=𝐗𝐖(1)𝐖(2)+𝐛(1)𝐖(2)+𝐛(2)=𝐗𝐖+𝐛.(5.1.2)
In order to realize the potential of multilayer architectures, we need one more key ingredient: a nonlinear activation function σ to be applied to each hidden unit following the affine transformation. For instance, a popular choice is the ReLU (rectified linear unit) activation function (Nair and Hinton, 2010) σ(x)=max(0,x) operating on its arguments elementwise. The outputs of activation functions σ(⋅) are called activations. In general, with activation functions in place, it is no longer possible to collapse our MLP into a linear model:
英語のヒント
多層の構造の潜在力を引き出すには、もう一つ鍵となる材料が必要である。アフィン変換に続いて各隠れユニットに適用される、非線形の活性化関数σである。たとえば、よく選ばれるのはReLU(正規化線形ユニット)活性化関数σ(x)=max(0,x)(Nair and Hinton, 2010)で、引数に成分ごとに作用する。活性化関数σ(⋅)の出力は活性と呼ばれる。一般に、活性化関数があれば、MLPを線形モデルに畳み込むことはもはやできない。
𝐇=σ(𝐗𝐖(1)+𝐛(1)),𝐎=𝐇𝐖(2)+𝐛(2).(5.1.3)
Since each row in 𝐗 corresponds to an example in the minibatch, with some abuse of notation, we define the nonlinearity σ to apply to its inputs in a rowwise fashion, i.e., one example at a time. Note that we used the same notation for softmax when we denoted a rowwise operation in Section 4.1.1.3. Quite frequently the activation functions we use apply not merely rowwise but elementwise. That means that after computing the linear portion of the layer, we can calculate each activation without looking at the values taken by the other hidden units.
英語のヒント
𝐗の各行はミニバッチの一つの事例に対応するので、記法を少々乱用して、非線形性σは入力に行ごとに、つまり一度に一つの事例ずつ適用されるものと定義する。4.1.1.3節で行ごとの演算を表したときにも、ソフトマックスに同じ記法を使ったことに注意してほしい。使う活性化関数は、単に行ごとではなく成分ごとに適用されることがきわめて多い。つまり、層の線形の部分を計算したら、ほかの隠れユニットがとる値を見ずに、各活性を計算できるのである。
To build more general MLPs, we can continue stacking such hidden layers, e.g., 𝐇(1)=σ1(𝐗𝐖(1)+𝐛(1)) and 𝐇(2)=σ2(𝐇(1)𝐖(2)+𝐛(2)), one atop another, yielding ever more expressive models.
英語のヒント
もっと一般的なMLPを作るには、たとえば𝐇(1)=σ1(𝐗𝐖(1)+𝐛(1))や𝐇(2)=σ2(𝐇(1)𝐖(2)+𝐛(2))のような隠れ層を次々と積み重ね続けて、ますます表現力の高いモデルを得られる。

5.1.1.4. Universal Approximators5.1.1.4 万能近似器

We know that the brain is capable of very sophisticated statistical analysis. As such, it is worth asking, just how powerful a deep network could be. This question has been answered multiple times, e.g., in Cybenko (1989) in the context of MLPs, and in Micchelli (1984) in the context of reproducing kernel Hilbert spaces in a way that could be seen as radial basis function (RBF) networks with a single hidden layer. These (and related results) suggest that even with a single-hidden-layer network, given enough nodes (possibly absurdly many), and the right set of weights, we can model any function. Actually learning that function is the hard part, though. You might think of your neural network as being a bit like the C programming language. The language, like any other modern language, is capable of expressing any computable program. But actually coming up with a program that meets your specifications is the hard part.
英語のヒント
脳がとても高度な統計解析をこなせることはわかっている。そこで、深いネットワークがいったいどれほど強力になりうるかを問う価値がある。この問いには何度も答えが出されてきた。たとえば、MLPの文脈ではCybenko (1989)で、また、隠れ層が一つの動径基底関数(RBF)ネットワークとみなせる形で、再生核ヒルベルト空間の文脈ではMicchelli (1984)で答えられている。これらの結果(と関連する結果)によれば、隠れ層が一つのネットワークでも、十分な数のノード(ことによるとばかげたほど多く)と正しい重みの組があれば、どんな関数でもモデル化できる。もっとも、その関数を実際に学習するのが難しいところである。ニューラルネットワークは、少しC言語のようなものだと考えるとよいかもしれない。C言語は、ほかの現代的な言語と同じく、計算可能などんなプログラムも表現できる。しかし、自分の仕様を満たすプログラムを実際に思いつくのが難しいところなのである。
Moreover, just because a single-hidden-layer network can learn any function does not mean that you should try to solve all of your problems with one. In fact, in this case kernel methods are way more effective, since they are capable of solving the problem exactly even in infinite dimensional spaces (Kimeldorf and Wahba, 1971, Schölkopf et al., 2001). In fact, we can approximate many functions much more compactly by using deeper (rather than wider) networks (Simonyan and Zisserman, 2014). We will touch upon more rigorous arguments in subsequent chapters.
英語のヒント
さらに、隠れ層が一つのネットワークがどんな関数でも学習できるからといって、すべての問題をそれで解こうとすべきだということにはならない。実際、この場合にはカーネル法のほうがずっと効果的である。カーネル法は、無限次元の空間でさえ問題を厳密に解けるからである(Kimeldorf and Wahba, 1971、Schölkopf et al., 2001)。実際、(幅を広げるのではなく)より深いネットワークを使うことで、多くの関数をずっと簡潔に近似できる(Simonyan and Zisserman, 2014)。もっと厳密な議論には、以降の章で触れる。