TL;DR
Dropout is a training trick for neural networks. On every training step, each hidden unit is independently set to zero with some probability , and the rest of the network carries on with what is left. At test time nothing is dropped, and the network uses all of its units.
The effect is that no unit can count on a specific neighbour being present, so each one has to learn features that are useful on their own. That reduces Overfitting and, as a side effect, trains something close to an average of a huge number of smaller networks.
Where you'll see it: in the fully connected layers of image classifiers and language models, in the attention and feed-forward blocks of many transformers, and as a standard default in deep learning libraries.
Intuition
A team where anyone might be absent
Picture a team that is told, every morning, that a random half of its members will be away. Nobody can rely on one particular colleague to fix a specific problem. Each person has to learn the whole job well enough to cover for others, and the team as a whole becomes sturdier. If the same people were always together, they could quietly become dependent on each other, with one person handling a narrow case that only works when a partner is there to set it up.
Neural networks do the same thing without help. Units in one layer tend to lock into pairs or small groups that only work together. Those groups can fit the training data very well, which is exactly the problem: the fit is partly memorised quirks of that data, and it breaks on new inputs. This is what the original paper called co-adaptation. Dropout breaks the groups apart by making every unit's neighbours unreliable.
The picture below is a single hidden layer on one step. Hidden 2 is dropped: its dashed connection to the output carries nothing, and whatever it received from the inputs is discarded.
flowchart LR i1((input 1)) --> h1((hidden 1)) i1 --> h2((hidden 2)) i2((input 2)) --> h1 i2 --> h2 i2 --> h3((hidden 3)) h1 --> o((output)) h3 --> o h2 -. "dropped this step" .-> o
On the next step a different random set of hidden units is dropped, so the network sees a different thinned version of itself every time.
Why this is a regulariser
A regulariser is anything that makes a model less eager to fit the training set perfectly. L2 Regularization does it by penalising large weights. Dropout does it by injecting noise into the forward pass. The network cannot rely on any one path, so it has to spread what it learns across many redundant paths. That redundancy is what generalises.
There is a second, more surprising way to see it. Each training step samples one of the exponentially many sub-networks you get by deleting units, and trains that sub-network on one example. Across the whole run, the weights are shared among all those sub-networks. At test time, the full network with scaled weights approximates the average of their predictions. That is the same idea as Ensemble Learning, done for the price of one extra random number per unit.
The math
Setting up
Consider one layer with activations , where is the number of hidden units and is the output of unit . Choose a keep probability with . The drop probability is . For each unit, draw an independent mask bit
so means "keep" and means "drop", each with the probabilities described in the Bernoulli distribution.
The training-time output is the elementwise product of the mask and the activations, divided by :
The division by is called inverted dropout. It is the form almost every modern library uses, and it is explained below.
Why divide by the keep probability
Look at the expected value of one unit's output. Since ,
On average, the training-time output equals the activation the unit would have produced with no dropout. So at test time we can simply use every unit with no scaling, and the expected input to the next layer is unchanged. That is the whole reason for the factor: it moves the scaling from test time to training time, so inference is free.
How noisy is a single unit?
Dropout does not change the average output, but it adds variance. For a single unit with fixed activation , the output takes the value with probability and with probability . Because for a bit, , and so
The noise grows as shrinks. With there is no noise at all, and with the variance equals .
- variance per unit of h squared
The backward pass
Dropout has no learned parameters, so there is nothing new to update. During Backpropagation, the gradient flowing into a unit is multiplied by the same mask and scale used in the forward pass. If a unit was dropped, its gradient is zero for that step. If it was kept, its gradient is multiplied by . The chain rule does the rest, which is why dropout drops into existing training code with one line.
Test-time behaviour
At inference the mask is switched off:
For a single linear layer with weights , the average of over all masks is exactly , so the test-time network gives the mean prediction of the thinned networks. For deeper networks this is only an approximation, because the nonlinearities do not commute with the average. In practice it works well enough that the original authors used it as the default.
Worked examples
Take a single unit with activation and keep probability .
- Mask outcome , probability : output .
- Mask outcome , probability : output .
- Expected output: . This matches the activation with no dropout, as the scaling promised.
- Second moment: . Variance .
- Check with the formula: . It matches.
Interpretation: the unit is right on average, but any single training step gives either a boost to or a silence to . The network learns to be robust to that swing.
A hidden layer has four units with activations . Use keep probability , so and the scale is .
- Draw a mask: . Unit 2 is dropped.
- Multiply elementwise: .
- Scale by : .
- This vector is what the next layer receives on this training step.
- At test time, the next layer receives unchanged.
Notice that the surviving units are amplified, so the next layer sees roughly the same total signal on average, even though a quarter of the units went silent.
A layer has units and we use drop probability , so . Assume each unit is kept independently.
- Expected number of kept units: , so about 819 units stay on each step.
- Variance of the kept count: .
- Standard deviation: .
- So on a typical step the number of active units is about . The layer is always strongly populated, and the noise is a small fraction of its width.
- Compare with on the same layer: kept on average, standard deviation . The relative noise is larger when is larger, but the layer still has many active units.
Interpretation: for a wide layer, moderate drop rates are safe because the random subset is still large. For a narrow layer, the same removes a much larger share of the capacity on every step.
Tradeoffs and failure modes
Dropout helps most when a model is large relative to its training data and overfits. It helps much less when the model is already small, when data is plentiful, or when another regulariser already does the job. It also slows training, because each step only updates a thinned network and the model usually needs more epochs to converge.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Convolutional feature maps with spatial correlation | Dropping single pixels barely removes information, because neighbours carry the same signal | Spatial dropout that drops whole channels, or Data Augmentation |
| Very small network on a lot of data | Noise costs accuracy without buying regularisation | No dropout, or a small rate such as |
| Batch normalisation directly after dropout | The variance of the normalisation statistics shifts between training and test, which can hurt accuracy | Place dropout after normalisation, or use a different regulariser |
| Forgetting to switch off dropout at test time | Predictions become random and scores drop | Make evaluation mode the default in your training loop |
| Using dropout as the only defence against Overfitting | Heavy overfitting can persist | Combine with Early Stopping and L2 Regularization |
The most common bug is the test-time switch. Frameworks expose a train and eval mode for exactly this reason, and forgetting to call eval mode is a silent error that looks like a model that generalises badly.
History
Dropout was introduced in 2012 by Geoffrey Hinton and colleagues. Their arXiv paper, "Improving neural networks by preventing co-adaptation of feature detectors", described randomly omitting hidden units during training to stop the units from co-adapting. The same year, the AlexNet network that won the ImageNet classification challenge used the technique in its fully connected layers, which helped show that it worked at scale.
A fuller treatment by Nitish Srivastava and co-authors followed in 2014 in the Journal of Machine Learning Research. It analysed the method more carefully, compared it with other regularisers, and popularised the name and the inverted scaling now used by default. The idea caught on because it needed no extra parameters, almost no code, and worked across many architectures. Later variants such as DropConnect and spatial dropout were built on the same principle.
Check yourself
QuestionRecall: what is the purpose of dropping units during training?Show answer
To stop units from co-adapting, so that no unit depends on a specific neighbour being present. This forces each unit to learn useful features on its own, which reduces overfitting. It also acts like training an average over many thinned sub-networks.
QuestionComputation: with keep probability and activation , what is the expected output of a unit under inverted dropout, and what is its variance?Show answer
The expected output is , because the scaling cancels the keep probability on average. The variance is , to two decimal places. The output takes the value with probability and with probability . Check: and .
QuestionWhy: why does inverted dropout divide by the keep probability during training rather than multiplying by it at test time?Show answer
Dividing during training keeps the expected activation the same as it is without dropout, so the test-time network can use all units with no change. Multiplying at test time would also work, but it adds a step to inference and is easy to forget. Dividing during training means the same forward pass code runs at test time with the mask simply turned off.
QuestionApplied: a team trains a 2048-unit layer and sees the validation loss rise while the training loss keeps falling. Should they raise the dropout rate, and what would you check first?Show answer
A rising gap between training and validation loss is the classic sign of overfitting, so a higher rate is a reasonable first move. Before changing it, check that dropout is actually switched off during validation, because a bug there would look like overfitting. Then try a moderate increase, such as from to , and watch the gap. A layer this wide still has many active units at high rates, so the change should not starve the network of capacity.
Sources
- Srivastava, Hinton, Krizhevsky, Sutskever, Salakhutdinov, Dropout: A Simple Way to Prevent Neural Networks from Overfitting, JMLR 2014: https://jmlr.org/papers/v15/srivastava14a.html
- Hinton et al., Improving neural networks by preventing co-adaptation of feature detectors, arXiv 2012: https://arxiv.org/abs/1207.0580
- Dropout (neural networks), Wikipedia: https://en.wikipedia.org/wiki/Dropout_(neural_networks)