Dropout in Depth
Subnetwork ensembles, adaptive L2 penalties and the noise-injection family.
Dropout looks like a hack: silence random units and hope for the best. Underneath are exact statements. For a softmax layer the weight-scaling rule computes an ensemble of exponentially many subnetworks exactly; for generalized linear models dropout is a ridge penalty that adapts to the Fisher information and spares rare but useful features; and in deep networks the randomness of the masks regularizes on its own, beyond the penalty it adds to the expected loss.
What you’ll learn
- Prove that the weight-scaling rule computes the normalized geometric mean of all dropout subnetworks of a softmax layer, show that this ensemble never has worse log loss than the average subnetwork, and explain why exactness ends at the first hidden nonlinearity.
- Derive the dropout penalty for linear regression and its quadratic approximation for generalized linear models, and read it as an penalty after rescaling each feature by its Fisher information.
- Separate dropout's explicit regularizer from the implicit effect of its noise, and describe the experiment that shows the noise matters.
- Evaluate the Bayesian reading of dropout and its critiques, and place DropConnect, Gaussian, spatial and block dropout, stochastic depth, LayerDrop, R-Drop and early dropout in one family.
An exact ensemble, and where exactness ends
Write , so . The log of the unnormalized geometric mean splits into a part that depends on and a part that does not:
The second part cancels when we normalize over . The first part is linear in , so the average passes straight through, and cancels the :
For the loss bound, write . By the weighted inequality of arithmetic and geometric means each product is at most the matching arithmetic average, so the normalizer is at most one:
The same computation for a single logistic unit gives (Baldi & Sadowski, 2013). Once a nonlinearity sits between the masks and the output, is no longer linear in , the expectation no longer passes through, and the deterministic pass only approximates the ensemble. Baldi and Sadowski describe deep networks by three recursive equations: holds exactly for every logistic unit, follows from the expected outputs of the layer below by linearity, and the only approximation is , made at every layer.
In which case does running the network with dropout switched off compute an ensemble of all dropout subnetworks exactly?
- Dropout on the inputs of a single softmax layer: the pass equals the normalized geometric mean
- Dropout anywhere in a ReLU network: the pass equals the arithmetic mean
- Dropout in a deep network, provided is close to 1
- Never; it is always an approximation
Show the answer
A. Dropout on the inputs of a single softmax layer: the pass equals the normalized geometric mean
The softmax's log is linear in the logits up to a term that does not depend on the class, and the logits are linear in the mask, so the expectation passes through exactly. A hidden nonlinearity breaks the linearity, leaving an approximation, good or bad depending on how nonlinear the units are over the range the masks explore.
Dropout as an adaptive penalty
Wager, Wang and Liang (2013) asked what dropout does to a model's objective. Apply inverted dropout to the features of a generalized linear model: with independent masks, so and .
Linear regression. The squared error of a noisy input is the clean error plus the variance of the noisy prediction, exactly:
Averaged over the data this is ridge regression with a separate weight per feature, : ridge on standardized features. GLMs. Now take , with convex log-partition function and loss . The term linear in averages to its clean value, so the noise adds a penalty:
by Jensen's inequality, and it does not involve the labels at all. A second-order Taylor expansion of around (the first-order term averages to zero) gives the quadratic penalty:
At the true parameter, estimates the Fisher information . So dropout is, to second order, an penalty applied after rescaling each feature by : it applies the penalty in a basis where the features have been balanced, although the loss's level sets need not be round. For logistic regression with :
Read the logistic penalty term by term. An example contributes only through features that are active on it (), and only if its prediction is uncertain ( large). A rare feature that, whenever it fires, helps make a confident prediction pays almost nothing, however large its weight; a plain penalty would charge it in full. Wager et al. confirmed in simulation that dropout beats when the signal lives in rare features, which fits dropout's success in document classification. And because ignores the labels, unlabeled data can be used to estimate it, which their semi-supervised variant exploits.
Inverted dropout with keep probability acts on the inputs of a linear regression trained with mean squared error. A feature has mean square . What coefficient multiplies in the penalty dropout adds to the mean squared error?
Show the answer
1
. The same dropout rate penalizes a feature with twice the scale four times as hard, which is why dropout on raw inputs behaves like ridge on standardized inputs.
Explicit and implicit effects
In a deep network, apply inverted dropout to a hidden layer and let map it to the outputs, with and the Hessian of the loss with respect to the outputs. The perturbation has mean zero and covariance , so a second-order expansion (keeping the Gauss–Newton part of the curvature) gives the explicit regularizer:
But dropout does more than add to the expected loss. Each step uses one random mask, so the update is the gradient of the expected objective plus mean-zero noise, much like the noise of small mini-batches. Wei, Kakade and Ma (2020) separated the two effects. Their "Dropout" averaged the loss over masks per update, which leaves the expected objective unchanged and only removes noise: for LSTM language models on Penn Treebank and WikiText-2, validation perplexity got steadily worse as grew. Adding back mean-zero noise with the covariance of dropout's gradient noise restored performance, and the analytic explicit regularizer plus this noise matched dropout. Two details matter: replacing the loss Hessian in the penalty by the identity worked poorly, and on the much larger WikiText-103 with a Transformer-XL the implicit effect largely disappeared.
The noise can also help optimization. Liu et al. (2023) found that for models that underfit (in their experiments, small vision models trained on ImageNet), dropout applied only in the first part of training ("early dropout") reached a lower final training loss than no dropout; they observed that it reduces the variance of mini-batch gradient directions early on, aligning them with the full-data gradient. For models that overfit they proposed the mirror image, "late dropout", switched on only after an initial phase.
Averaging the loss over dropout masks per update keeps dropout's expected objective fixed. Validation perplexity of LSTM language models got worse as grew. What does that show?
- The explicit penalty was implemented incorrectly
- More masks per step overfit because they see more subnetworks
- The randomness of single-mask updates is itself a regularizer, beyond the penalty in the expected objective
- Dropout works only through its effect on the learning rate
Show the answer
C. The randomness of single-mask updates is itself a regularizer, beyond the penalty in the expected objective
With the expected objective held fixed, the only thing changes is the variance of the update. Worse results with less noise mean the noise was helping, an implicit regularization effect, and adding matched noise back recovered the performance.
The Bayesian reading and its critiques
Gal and Ghahramani (2016) gave dropout a probabilistic interpretation: training a network with dropout and an penalty can be cast as approximate variational inference for a Bayesian neural network, with a variational distribution in which all the weights leaving a unit are switched on or off together by one Bernoulli variable. Keeping dropout on at test time and averaging many stochastic passes ("MC dropout") then approximates the posterior predictive distribution, and the spread of the passes serves as an uncertainty estimate at no extra training cost. The Machine Learning course's lesson Uncertainty in Neural Networks compares it with deep ensembles in practice.
The reading has drawn sharp critiques. Osband (2016) pointed out that with a fixed dropout rate the spread of MC dropout predictions does not shrink as the training set grows, unlike a posterior, so it reflects the noise of the procedure more than uncertainty about the parameters. Hron, Matthews and Ghahramani (2018) showed that the log-uniform prior used by variational Gaussian dropout (Kingma, Salimans & Welling, 2015) is improper and generally yields an improper posterior, so that Bayesian objective is ill-posed; the sparsity the method produces cannot be explained by the Bayesian or minimum-description-length arguments offered for it. They also showed that, for Bernoulli and Gaussian dropout alike, the approximating distribution is singular with respect to the true posterior, which leaves the standard variational objective undefined, and they proposed a quasi-KL divergence that makes the remedies used for MC dropout rigorous.
Think first Why can't the spread of MC dropout predictions concentrate as the dataset grows, the way a true posterior does?
The variational family fixes the shape of the uncertainty in advance: each weight is either present or absent with the fixed probability , so the spread of the sampled networks is set by and by the size of the learned weights, not by the amount of data. A Bayesian posterior over a well-specified model narrows roughly like . Unless itself is learned and pushed toward 1 as data grow, the "posterior" keeps its width.
A family of structured noise
| Variant | What is dropped or perturbed | Why |
|---|---|---|
| Gaussian dropout | Each unit is multiplied by noise from , the same mean and variance as inverted Bernoulli dropout | No test-time rescaling; Srivastava et al. (2014) found it worked as well or slightly better |
| DropConnect | Individual weights, so each unit sees a random subset of its inputs (Wan et al., 2013) | A finer-grained family of subnetworks |
| SpatialDropout | Whole channels of a convolutional feature map (Tompson et al., 2015) | Neighboring activations are correlated, so dropping single pixels hides little |
| DropBlock | Contiguous square regions of a feature map (Ghiasi, Lin & Le, 2018) | Removes whole local evidence, forcing the network to use other regions |
| Stochastic depth, LayerDrop | Whole residual blocks (Huang et al., 2016) or transformer layers (Fan, Grave & Joulin, 2020) | LayerDrop also lets a trained model be cut to a smaller depth at inference without fine-tuning |
| R-Drop | Two dropout masks per example, plus the symmetric KL divergence between the two predictions (Liang et al., 2021) | Makes the sampled subnetworks agree, shrinking the gap with the full test-time network |
| Early and late dropout | Dropout only before, or only after, a chosen point in training (Liu et al., 2023) | Early dropout eases underfitting; late dropout targets overfitting |
Dropout also interacts badly with batch normalization. A dropped-out layer has a different activation variance during training than at test time, but a following batch-norm layer keeps using the running variance it accumulated with dropout on. Li, Chen, Hu and Yang (2019) called this mismatch variance shift and traced the poor results of combining the two to it; placing dropout after the last batch-norm layer avoids it. In convolutional networks with batch normalization, dropout largely gave way to augmentation, weight decay and stochastic depth.
Key takeaways
- For inverted dropout on the inputs of one softmax layer, the deterministic pass is exactly the normalized geometric mean of all subnetworks, whose log loss never exceeds the average subnetwork's; hidden nonlinearities make it an approximation.
- For GLMs, dropout adds the label-free penalty , to second order : ridge after rescaling by the diagonal Fisher information, gentle on rare but useful features.
- In deep networks the explicit penalty weights each unit's squared activation by the loss curvature along it, and the mask noise adds an implicit regularization of its own (Wei, Kakade & Ma, 2020).
- MC dropout reads dropout as variational inference (Gal & Ghahramani, 2016), but its spread does not concentrate with data at a fixed rate, and variational Gaussian dropout's log-uniform prior is improper (Hron et al., 2018): treat its uncertainty as an empirical claim.
- The family (Gaussian, DropConnect, spatial, block, stochastic depth, LayerDrop, R-Drop, early dropout) varies what is dropped to match the structure of the network; before batch normalization, dropout causes a train–test variance shift.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
For inverted dropout on the inputs of a softmax layer, the deterministic test-time pass equals which ensemble of the subnetworks?
- The arithmetic mean of their predicted probabilities
- The normalized geometric mean of their predicted probabilities, weighted by the mask probabilities
- The single most probable subnetwork, with all units kept
- The median of their predictions
Show the answer
B. The normalized geometric mean of their predicted probabilities, weighted by the mask probabilities
The log of a softmax is the logit minus a class-independent term, and the logits are linear in the mask, so the weighted geometric mean renormalizes to . Its log loss is never worse than the average subnetwork's, by the inequality of arithmetic and geometric means.
Dropout on the features of a logistic regression adds, to second order, . Which feature can keep a large weight cheaply?
- A feature that is active on every example, where predictions are uncertain
- Any feature with a large average value
- None: the penalty is the same as for every feature
- A rare feature that, whenever it is active, contributes to a confident prediction
Show the answer
D. A rare feature that, whenever it is active, contributes to a confident prediction
A feature pays only on examples where it is active (), weighted by , which is small for confident predictions. Rare, discriminative features escape most of the penalty, unlike under .
For a generalized linear model, why can the dropout penalty be estimated from unlabeled data?
- Because the labels enter the loss linearly through , whose expectation over the masks is unchanged; only the log-partition term is perturbed
- Because dropout ignores the loss function entirely
- Because the Fisher information never depends on
- It cannot; the penalty depends on every label
Show the answer
A. Because the labels enter the loss linearly through , whose expectation over the masks is unchanged; only the log-partition term is perturbed
leaves the term linear in untouched, so involves inputs only. Wager et al. used this to build a semi-supervised regularizer.
What did Hron, Matthews and Ghahramani (2018) show about variational Gaussian dropout with a log-uniform prior?
- It is too expensive to train on large networks
- Its prior is too informative, so the data are ignored
- The prior is improper and generally gives an improper posterior, so the Bayesian objective is ill-posed
- It is exactly equivalent to Bernoulli dropout with
Show the answer
C. The prior is improper and generally gives an improper posterior, so the Bayesian objective is ill-posed
An improper prior can be harmless when the posterior is still normalizable; here it generally is not, so the variational objective has no well-defined Bayesian target, and the sparsity it produces needs another explanation.
Further reading
- P. Baldi & P. J. Sadowski, "Understanding dropout," NeurIPS (2013).
- S. Wager, S. Wang & P. Liang, "Dropout training as adaptive regularization," NeurIPS (2013).
- C. Wei, S. Kakade & T. Ma, "The implicit and explicit regularization effects of dropout," ICML (2020).
- Y. Gal & Z. Ghahramani, "Dropout as a Bayesian approximation: representing model uncertainty in deep learning," ICML (2016).
- J. Hron, A. G. de G. Matthews & Z. Ghahramani, "Variational Bayesian dropout: pitfalls and fixes," ICML (2018).