Dropout
Dropout regularizes neural networks by randomly zeroing neuron activations with probability p during each training forward pass, preventing co-adaptation and acting as implicit model averaging across thinned subnetworks. With modern inverted dropout, surviving activations are scaled by 1 / (1 - p) during training so their expected value matches inference without requiring scaling at test time.


The Core Idea Behind Dropout
When applying dropout, we randomly zero out (“drop”) a fraction of neuron activations in a layer on each forward pass during training. If a neuron is dropped, its output becomes , so it contributes neither to the forward pass nor to the backward gradient update on that iteration. This prevents neurons from over-relying on specific co-adaptations and encourages more redundant, robust representations.
Expected Value of Activations & Scaling
Let:
- : the dropout probability (probability a neuron is dropped).
- : the neuron’s original activation before dropout.
- : the neuron’s output after dropout.
1. Why Unscaled Dropout Causes a Train-Test Mismatch
Without scaling, a neuron’s output during training is:
Its expected value during training is therefore shrunk by :
At inference time (eval mode), all neurons stay active () with output . Without compensation, activations passed to downstream layers would be times larger at test time than during training!
2. Inverted Dropout (Standard Practice)
In the original formulation (Srivastava et al., 2014), activations were left unscaled during training and multiplied by at test time. Modern frameworks (PyTorch, TensorFlow, JAX) instead use inverted dropout, applying the compensation factor during training:
Taking the expectation over the random binary mask:
Because the expected activation already equals during training:
- Inference requires zero extra work: all weights and activations are used directly at test time without scaling.
- Backpropagation: the exact same binary mask and scaling factor are applied to gradients flowing back through that layer during training.