Start studying
Module 2 · Deep Learning Module contents
Module 2  ·  Card 20 / 25intermediate

Dropout

Dropout randomly switches off a fraction of neurons during each training step.

This stops the network relying too heavily on any single neuron.

It effectively trains a huge ensemble of thinner networks at once.

A typical dropout rate is between 0.2 and 0.5.

It is turned off at inference time so the full network is used.

Learn in depth ↓
Module 02 · Deep Learning · 25 concepts
In depth  /  15 lines

Dropout, in more detail

Dropout switches off a random selection of neurons on every training step.

A rate of 0.5 means each neuron has a coin-flip chance of being ignored this step.

The choice is remade for every batch, so a different network trains each time.

The point is to stop the network leaning on any single neuron.

A neuron that might vanish cannot be relied on, so the others must cover the same ground.

That spreads the representation out instead of concentrating it in a few units.

It also behaves like training an enormous ensemble of thinner networks that share weights.

At prediction time nothing is dropped, since you want the full network and a stable answer.

The activations are scaled to account for more neurons being active than during training.

Frameworks handle that scaling for you, which is why models have a train and an eval mode.

Forgetting to switch to eval mode is a classic bug that quietly degrades results.

Typical rates run from 0.2 to 0.5, with the higher end on wide fully connected layers.

Too much dropout starves the network and it underfits instead.

Convolutional layers use it sparingly, since their weights are already shared and constrained.

Transformers use it lightly, and the largest models often train with almost none.

Want the full technical article? Wikipedia ↗
Deep dive

What is underneath Dropout

Delete neurons at random

During training, each unit's output is multiplied by a random zero or one, so a different subnetwork is trained on every batch.

rj∼Bernoulli(1−p)y~j=rj yjr_j \sim \mathrm{Bernoulli}(1 - p) \qquad \tilde{y}_j = r_j \, y_j
  • pp: the drop probability, the fraction of units switched off.
  • rjr_j: a coin flip for unit jj, redrawn on every single forward pass.

At p=0.5p = 0.5, half the units are gone from any given step, and which half changes constantly.

The scaling problem, and where it is solved

Dropping units changes the expected size of the output, and the next layer's weights were tuned for the undropped size.

E[y~j]=(1−p) yj\mathbb{E}[\tilde{y}_j] = (1 - p) \, y_j

Left alone, activations would shrink by a factor of 1−p1 - p at training time and jump back up at inference, which is a different function.

y~j=rj yj1−p\tilde{y}_j = \frac{r_j \, y_j}{1 - p}

Dividing by 1−p1 - p during training restores the expectation, and this is called inverted dropout.

It is the version every framework implements, and the reason is efficiency rather than elegance: inference then needs no dropout code at all, which is the path that runs a billion times.

Training and inference

E ⁣[rjyj1−p]=(1−p)yj1−p=yj\mathbb{E}\!\left[ \frac{r_j y_j}{1 - p} \right] = \frac{(1-p) y_j}{1-p} = y_j

At inference, dropout is simply switched off and the layer is the identity.

Forgetting to switch it off is a classic bug, and it looks like a model that gives a different answer every time you ask it the same question.

One forward pass, in order

  1. Draw one Bernoulli sample per unit.
  2. Multiply each activation by its sample, zeroing the dropped ones.
  3. Divide what survives by 1−p1 - p.
  4. Carry on to the next layer.
  5. At inference, skip all four steps.

Why randomly deleting things helps

A unit cannot rely on any particular other unit being present, because that one might be gone next step.

So the network cannot build long chains of co-adapted units that only work together, and has to spread the representation out redundantly.

It is also close to training an exponentially large ensemble of thinned networks and averaging them at test time.

That is the other standard explanation, and the one that connects dropout to the rest of regularisation.

Modern large models use it sparingly: with enough data the overfitting it fights is no longer the binding constraint, and the noise it adds costs more than it saves.

Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
What does dropout do during training?
Deep Learning

25 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close