Skip to the content

fatehi.devx2Learning

Deep learning

Regularisation

Ways of stopping a network from learning its training data by heart: penalties on the weights, dropout, more and varied data, stopping early.

Learning by heart

A network with millions of weights can fit its training data almost perfectly, noise and accidents included, and then do worse on data it has not seen: overfitting. Regularisation is everything done to prefer the solution that carries over: limits on the weights, noise in training, more data, or stopping before the fit becomes too close.

The common kinds

Weight decay adds a penalty for large weights to the loss, or shrinks every weight a little at each step, so the network uses many small weights rather than a few large ones. Early stopping watches the loss on held-out data and stops when it stops falling. Data augmentation shows the network the same examples changed in ways that should not matter. And dropout (Srivastava and colleagues, 2014) adds noise inside the network itself.

Dropout

During training, dropout sets each number of a vector to 0 with probability p, a new random choice at every step, and multiplies the numbers it keeps by 1/(1 − p) so that their sum stays the same on average. At test time it does nothing. No unit can count on any particular other being there, so the network cannot build fragile arrangements of a few units; it learns more redundant, sturdier features, a little like training many thinned networks that share their weights and averaging them.

Dropout while training: at every step a new random mask drops some numbers (more often here than the paper’s rate of 0.1, to be seen), and the kept ones are scaled up by 1/(1 − p).

Test yourself

  1. Why are the kept numbers multiplied by 1/(1 − p)?

    So that the vector’s sum stays the same on average; at test time, when nothing is dropped, the next layer then sees numbers of the same size as in training.

  2. What does dropout do at test time?

    Nothing: every number is kept and none is scaled.

  3. Where does the Transformer apply dropout?

    To each sublayer’s output before the residual addition, and to the sums of embeddings and position encodings, with p = 0.1 in the base model.

Where it leads

Kept in this browser only, never sent.

Paths through it