プリンキピア

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

5.6. Dropout5.6 ドロップアウト

Let’s think briefly about what we expect from a good predictive model. We want it to peform well on unseen data. Classical generalization theory suggests that to close the gap between train and test performance, we should aim for a simple model. Simplicity can come in the form of a small number of dimensions. We explored this when discussing the monomial basis functions of linear models in Section 3.6. Additionally, as we saw when discussing weight decay (ℓ2 regularization) in Section 3.7, the (inverse) norm of the parameters also represents a useful measure of simplicity. Another useful notion of simplicity is smoothness, i.e., that the function should not be sensitive to small changes to its inputs. For instance, when we classify images, we would expect that adding some random noise to the pixels should be mostly harmless.
英語のヒント
よい予測モデルに何を期待するかを、手短に考えてみよう。見たことのないデータでよい性能を出してほしい。古典的な汎化の理論によれば、訓練とテストの性能の差を埋めるには、単純なモデルをめざすべきである。単純さは、次元の数が少ないという形をとることがある。これは、3.6節で線形モデルの単項式の基底関数を論じたときに探った。さらに、3.7節で重み減衰(ℓ2正則化)を論じたときに見たように、パラメータのノルム(の逆数)も単純さの有用な尺度になる。単純さのもう一つの有用な概念はなめらかさ、つまり関数が入力の小さな変化に敏感であるべきではないということである。たとえば、画像を分類するとき、画素に無作為なノイズを少し加えても、ほとんど害はないはずだと期待するだろう。
Bishop (1995) formalized this idea when he proved that training with input noise is equivalent to Tikhonov regularization. This work drew a clear mathematical connection between the requirement that a function be smooth (and thus simple), and the requirement that it be resilient to perturbations in the input.
英語のヒント
Bishop (1995)は、入力にノイズを加えて訓練することがティホノフ正則化と同等であることを証明したとき、この考えを形式化した。この研究は、関数がなめらか(したがって単純)であるという要件と、入力の摂動に対して頑丈であるという要件のあいだに、はっきりした数学的なつながりをつけた。
Then, Srivastava et al. (2014) developed a clever idea for how to apply Bishop’s idea to the internal layers of a network, too. Their idea, called dropout, involves injecting noise while computing each internal layer during forward propagation, and it has become a standard technique for training neural networks. The method is called dropout because we literally drop out some neurons during training. Throughout training, on each iteration, standard dropout consists of zeroing out some fraction of the nodes in each layer before calculating the subsequent layer.
英語のヒント
その後、Srivastava et al. (2014)は、Bishopの考えをネットワークの内部の層にも当てはめる方法について、賢い着想を得た。ドロップアウトと呼ばれるその着想は、順伝播のあいだに各内部層を計算するときにノイズを注入するもので、ニューラルネットワークを訓練するための標準的な手法になった。この方法がドロップアウトと呼ばれるのは、訓練中に文字どおり一部のニューロンを脱落させる(ドロップアウトする)からである。訓練全体を通じて、各反復で、標準的なドロップアウトは、次の層を計算する前に、各層のノードの一部を0にする。
To be clear, we are imposing our own narrative with the link to Bishop. The original paper on dropout offers intuition through a surprising analogy to sexual reproduction. The authors argue that neural network overfitting is characterized by a state in which each layer relies on a specific pattern of activations in the previous layer, calling this condition co-adaptation. Dropout, they claim, breaks up co-adaptation just as sexual reproduction is argued to break up co-adapted genes. While such an justification of this theory is certainly up for debate, the dropout technique itself has proved enduring, and various forms of dropout are implemented in most deep learning libraries.
英語のヒント
はっきりさせておくと、Bishopとのつながりは、筆者らが独自の筋書きを当てはめたものである。ドロップアウトの元の論文は、有性生殖との意外なたとえを通して直観を与えている。その著者たちは、ニューラルネットワークの過学習は、各層が前の層の活性の特定のパターンに頼っている状態として特徴づけられると論じ、この状態を共適応と呼んでいる。彼らの主張では、有性生殖が共適応した遺伝子を引き離すと論じられるのとちょうど同じように、ドロップアウトは共適応を崩す。この理論のそうした正当化には確かに議論の余地があるが、ドロップアウトの手法そのものは長く使われ続けており、さまざまな形のドロップアウトがほとんどの深層学習のライブラリに実装されている。
The key challenge is how to inject this noise. One idea is to inject it in an unbiased manner so that the expected value of each layer—while fixing the others—equals the value it would have taken absent noise. In Bishop’s work, he added Gaussian noise to the inputs to a linear model. At each training iteration, he added noise sampled from a distribution with mean zero ϵ∼𝒩(0,σ2) to the input 𝐱, yielding a perturbed point 𝐱′=𝐱+ϵ. In expectation, E[𝐱′]=𝐱.
英語のヒント
鍵となる難題は、このノイズをどう注入するかである。一つの考えは、偏りのないやり方で注入して、各層の期待値が(ほかの層を固定したまま)ノイズがない場合にとったであろう値に等しくなるようにすることである。Bishopの研究では、線形モデルへの入力にガウスノイズを加えた。各訓練反復で、平均0の分布から抽出したノイズϵ∼𝒩(0,σ2)を入力𝐱に加え、摂動を受けた点𝐱′=𝐱+ϵを得た。期待値ではE[𝐱′]=𝐱となる。
In standard dropout regularization, one zeros out some fraction of the nodes in each layer and then debiases each layer by normalizing by the fraction of nodes that were retained (not dropped out). In other words, with dropout probability p, each intermediate activation h is replaced by a random variable h′ as follows:
英語のヒント
標準的なドロップアウト正則化では、各層のノードの一部を0にし、それから、残された(脱落しなかった)ノードの割合で正規化することで、各層の偏りを取り除く。言い換えれば、ドロップアウトの確率をpとして、各中間の活性hは次のように確率変数h′で置き換えられる。
h′={0 with probability ph1−p otherwise(5.6.1)
By design, the expectation remains unchanged, i.e., E[h′]=h.
英語のヒント
設計上、期待値は変わらない。つまりE[h′]=hである。
import torch
from torch import nn
from d2l import torch as d2l