Dropout is a regularization technique that randomly sets a fraction of a neural network's units to zero during each training step, which discourages units from co-adapting and reduces overfitting. At test time dropout is turned off and the trained weights are used directly.
What dropout is and why it exists
Dropout is a regularization technique for neural networks that randomly removes units, along with their incoming and outgoing connections, during training. On each training example or mini-batch, every unit in a dropout layer is kept with some probability and otherwise set to zero. Because the set of surviving units changes from step to step, the network never trains the same configuration twice. The method was introduced by Geoffrey Hinton and colleagues in 2012 and described in full by Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov in the 2014 paper Dropout: A Simple Way to Prevent Neural Networks from Overfitting, published in the Journal of Machine Learning Research.
The motivation is overfitting. A large network with many parameters can memorize noise in the training set and generalize poorly to new data. Dropout addresses this by preventing complex co-adaptations, situations where a feature detector is only useful in the presence of several other specific detectors. When any unit can vanish at any step, each unit must produce features that are useful on their own rather than relying on a fixed set of neighbors. The result is a representation that is more redundant and less brittle.
Dropout is cheap, easy to add to almost any layer, and was one of the techniques that helped deep networks scale in the early 2010s. It is most effective on large, densely connected models that would otherwise overfit, and it composes with other regularizers rather than replacing them.
- Dropout randomly zeroes units during training, changing the active subnetwork every step.
- Its purpose is to reduce overfitting by breaking co-adaptation between units.
- It was introduced by Hinton et al. (2012) and formalized by Srivastava et al. (JMLR 2014).
- Each surviving unit must learn features useful without depending on specific neighbors.
The dropout mask and inverted scaling
Mechanically, dropout multiplies a layer's activations by a random binary mask. For drop probability p, each element of the mask is drawn independently from a Bernoulli distribution that returns 1 with probability 1 minus p (the keep probability) and 0 with probability p. Multiplying the input by this mask zeroes the dropped units and passes the rest through unchanged.
Zeroing units lowers the expected sum of activations, so a correction is needed to keep the scale consistent between training and inference. The standard modern approach is inverted dropout: during training the kept activations are divided by the keep probability 1 minus p, which restores the expected value of the layer's output. Because the scaling happens at training time, no adjustment is required at inference, where the layer simply passes its input through. This is exactly how frameworks implement it. The PyTorch documentation states that outputs are scaled by a factor of 1 / (1 minus p) during training, and that during evaluation the module computes an identity function.
The older alternative, sometimes called standard dropout, leaves training activations unscaled and instead multiplies all weights by the keep probability at test time. Both schemes aim to match the expected activation magnitude between the two phases; inverted dropout is preferred because it keeps inference code free of any dropout-specific step.
- The mask is drawn from a Bernoulli distribution with keep probability 1 minus p.
- Inverted dropout divides kept activations by 1 minus p during training.
- With inverted dropout, inference needs no rescaling and acts as identity.
- Standard dropout instead scales weights by the keep probability at test time.
Training versus inference behavior
Dropout behaves differently in the two phases of a model's life. During training it is active: units are randomly zeroed and kept activations are rescaled. During inference it is disabled and the full network runs deterministically. Forgetting to switch modes is a common bug, because a network left in training mode at test time will produce noisy, non-reproducible predictions, while a network left in evaluation mode during training will not regularize at all.
In practice this switch is controlled by a single flag. Deep learning frameworks expose train and eval modes that toggle dropout (and other stochastic layers) for the whole model at once. In PyTorch, calling model.train() enables dropout and model.eval() disables it, so the same module definition produces stochastic behavior while learning and deterministic behavior while serving.
Conceptually, training samples one of an exponential number of thinned subnetworks at each step, and a single forward pass at test time approximates averaging over all of them. The Srivastava et al. paper frames the trained network as an inexpensive approximation to an ensemble of these subnetworks, which is part of why a single deterministic forward pass at inference works well.
- Dropout is on during training and off during inference.
- In PyTorch, model.train() enables it and model.eval() disables it.
- Leaving the wrong mode set causes either no regularization or noisy predictions.
- A single test-time pass approximates averaging the trained subnetworks.
Variants and use in modern architectures
Several variants adapt the basic idea to different layer types. DropConnect, introduced by Wan, Zeiler, Zhang, LeCun, and Fergus at ICML 2013, generalizes dropout by randomly zeroing individual weights rather than whole units, so each unit receives input from a random subset of the previous layer. Spatial dropout, from Tompson, Goroshin, Jain, LeCun, and Bregler in Efficient Object Localization Using Convolutional Networks (CVPR 2015) and exposed in PyTorch as nn.Dropout2d, drops entire feature-map channels at once, which fits convolutional layers better because neighboring pixels in a channel are highly correlated and dropping them independently has little effect.
How heavily dropout is applied has shifted with architecture. In the fully-connected and early convolutional networks of the 2010s, drop probabilities around 0.5 on hidden layers were common. Modern transformer models use dropout more sparingly, typically applying small rates on attention weights and on the residual or feed-forward paths rather than throughout, and some very large models reduce or omit it because the sheer scale of data already limits overfitting.
Dropout also underlies a method for uncertainty estimation. Monte Carlo dropout, from Yarin Gal and Zoubin Ghahramani in Dropout as a Bayesian Approximation (ICML 2016), keeps dropout active at inference and runs multiple stochastic forward passes. The spread across those passes serves as an approximate measure of predictive uncertainty, reinterpreting dropout as approximate Bayesian inference rather than only as a regularizer.
- DropConnect zeroes individual weights instead of whole units (Wan et al., ICML 2013).
- Spatial dropout (nn.Dropout2d) drops entire channels, suiting convolutional layers.
- Transformers use dropout sparingly, often only on attention and residual paths.
- Monte Carlo dropout keeps dropout on at test time to estimate uncertainty (Gal and Ghahramani, 2016).
Relationship to other regularizers
Dropout is one of several tools for controlling overfitting, and it is usually combined with others rather than used alone. L2 weight decay penalizes large weights and shrinks the parameter magnitudes, addressing overfitting through the size of the weights, while dropout addresses it through the structure of the activations. The two are complementary and frequently appear together, with the Srivastava et al. paper noting that constraining weight norms alongside dropout can help.
Batch normalization interacts with dropout in subtler ways. Batch norm normalizes activations using mini-batch statistics and has its own regularizing effect through the noise of those statistics, which can reduce or remove the need for dropout in some architectures. Because both inject noise and both behave differently in train and eval modes, stacking them carelessly can hurt, and many modern convolutional designs lean on batch norm and use little or no dropout.
Early stopping, which halts training when validation performance stops improving, is another orthogonal control. None of these methods is a substitute for the others. The right combination depends on model size, dataset size, and architecture, and dropout remains a default choice for densely connected and transformer layers where it reliably narrows the gap between training and validation accuracy.
- L2 weight decay constrains weight magnitude; dropout perturbs activations. They combine well.
- Batch normalization can overlap with dropout's effect and is sometimes used instead.
- Early stopping is an orthogonal regularizer that limits training time.
- The best mix depends on model and dataset size; dropout is a strong default for dense and transformer layers.
Key takeaways
- Dropout randomly zeroes a fraction p of units during training so the network cannot rely on fixed co-adapted detectors.
- The mask is Bernoulli with keep probability 1 minus p; inverted dropout divides kept activations by 1 minus p so inference needs no rescaling.
- Dropout is active during training and disabled at inference; in PyTorch this is controlled by model.train() and model.eval().
- Training samples one of exponentially many thinned subnetworks, and a single test-time pass approximates averaging that ensemble.
- Variants include DropConnect (drops weights) and spatial dropout (drops channels); transformers apply dropout sparingly.
- Monte Carlo dropout reuses dropout at inference to produce uncertainty estimates, interpreting it as approximate Bayesian inference.
Frequently asked questions
Related terms
Related reading
Sources
- Dropout: A Simple Way to Prevent Neural Networks from Overfitting
- Improving neural networks by preventing co-adaptation of feature detectors
- Regularization of Neural Networks using DropConnect
- Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning
- Dropout (PyTorch documentation)
Put the idea into practice
MemX is an AI memory agent built on these ideas: store anything, skip the folders, and find it again by asking in plain English.
Try MemX Free