Dropout
During training, dropout switches off a random share of the numbers flowing through the model, a different share every time. The model cannot rely on any one number, so it learns patterns that survive losing a few: it overfits less.
Mask seed 2017
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | … 8 more | sum of all 16 | |
|---|---|---|---|---|---|---|---|---|---|---|
| input | −0.93 | −0.38 | 0.43 | 0.25 | −1.00 | 0.54 | −0.41 | −0.41 | … | −7.02 |
| output | −1.03 | −0.42 | 0.47 | 0.28 | −1.11 | 0.60 | −0.45 | −0.46 | … | −6.97 |
| average of 1,000 masks | −0.91 | −0.38 | 0.43 | 0.26 | −0.98 | 0.55 | −0.41 | −0.41 | … | −6.93 |
This mask drops 2 of 16 values and multiplies the rest by 1.111. Over 1,000 masks the average differs from the input by at most 0.04.
Why rescale, and why switch it off?
Dropping a share p of the values makes the vector smaller on average. Multiplying the survivors by 1 / (1 − p) puts the average back: with p = 0.1, the nine in ten that survive are multiplied by about 1.11. The last row shows the average over 1,000 different masks: it comes back to the input, give or take chance.
When the model translates, there is nothing to learn, and we want the same answer every time, so dropout is off: every value passes unchanged. Because of the rescaling during training, the values the next layer sees have the same size in both cases.
In the paper (5.4)
“We apply dropout to the output of each sub-layer, before it is added to the sub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the positional encodings in both the encoder and decoder stacks. For the base model, we use a rate of P_drop = 0.1.”