Dropout & Its Bayesian Interpretation

Rigorous derivation of dropout as a regularizer: the forward pass with random masks, inverted dropout scaling, the connection to model averaging over exponentially many subnetworks, and the MC Dropout interpretation as approximate Bayesian inference.

Intermediate

Table of Contents

  1. Learning Objectives
  2. Notation
  3. Core Intuition
  4. Dropout: Formulation
  5. Inverted Dropout
  6. Dropout as Ensemble Averaging
  7. Effect on Co-adaptation
  8. MC Dropout: Bayesian Interpretation
  9. Dropout in Different Architectures
  10. Common Pitfalls
  11. Summary
  12. Exercises

Learning Objectives

  1. Define dropout mathematically as multiplication by a random binary mask.
  2. Derive the expected output and show it equals the deterministic scaled output.
  3. Explain dropout as an implicit ensemble of 2n2^n subnetworks.
  4. Derive the MC Dropout uncertainty estimate.
  5. Understand when and where to apply dropout (and when not to).

Notation

  • pp — dropout probability (probability of zeroing a unit)
  • mBernoulli(1p)d\mathbf{m} \sim \text{Bernoulli}(1-p)^d — binary mask vector
  • hRd\mathbf{h} \in \mathbb{R}^d — hidden activations
  • h~=mh\tilde{\mathbf{h}} = \mathbf{m} \odot \mathbf{h} — dropped activations

Core Intuition

During training, dropout randomly "turns off" each neuron with probability pp. This forces the network to not rely on any single neuron — every neuron must be useful independently. At test time, all neurons are active but scaled, effectively averaging over all possible subnetworks. This acts as a powerful regularizer that reduces co-adaptation between neurons.

Dropout Regularization

L1L2L3L4Each forward pass uses a different thinned subnetwork
Active capacity: 70%
Dropout p
0.30
ActiveDropped
Insight: Dropout randomly zeros neurons during training, forcing the network to learn redundant representations. At test time all neurons are active but scaled — ensemble of 2ⁿ subnetworks.

Dropout: Formulation

Training: For each forward pass, sample a mask m{0,1}d\mathbf{m} \in \{0,1\}^d with miiidBernoulli(1p)m_i \overset{\text{iid}}{\sim} \text{Bernoulli}(1-p):

h~=mh.(1)\tilde{\mathbf{h}} = \mathbf{m} \odot \mathbf{h}. \tag{1}

The output of the next layer: z=Wh~+b\mathbf{z} = \mathbf{W}\tilde{\mathbf{h}} + \mathbf{b}.

Test time (naive): Use the full network but scale: E[h~]=(1p)h\mathbb{E}[\tilde{\mathbf{h}}] = (1-p)\mathbf{h}.

So at test time: multiply weights by (1p)(1-p).


Inverted Dropout

In practice, scale during training instead (avoids modifying test-time code):

h~=11pmh.(2)\tilde{\mathbf{h}} = \frac{1}{1-p}\mathbf{m} \odot \mathbf{h}. \tag{2}

Now E[h~]=h\mathbb{E}[\tilde{\mathbf{h}}] = \mathbf{h} — the expected output matches the deterministic network. At test time, no modification is needed.


Dropout as Ensemble Averaging

A network with dd units and dropout creates 2d2^d possible subnetworks (one for each binary mask). Each forward pass trains one subnetwork. The test-time output (with scaling) approximates the geometric average of all 2d2^d subnetworks' predictions.

Theorem (Baldi & Sadowski, 2013). For linear networks, the dropout-averaged output exactly equals the scaled deterministic output. For nonlinear networks, it is an approximation.

Ensemble perspective:

y^test12dmf(x;θ,m).(3)\hat{y}_{\text{test}} \approx \frac{1}{2^d}\sum_{\mathbf{m}} f(\mathbf{x}; \boldsymbol\theta, \mathbf{m}). \tag{3}

This is intractable to compute directly but is approximated by the scaled deterministic forward pass.


Effect on Co-adaptation

Without dropout, neurons can "co-adapt" — one neuron compensates for another's mistakes. This creates fragile representations. With dropout:

  • Each neuron must be independently useful (since its partners may be absent).
  • Features become more robust and transferable.
  • Effective model capacity is reduced (regularization).

Analogy: Training a team where random members are absent each day forces everyone to be versatile.


MC Dropout: Bayesian Interpretation

Theorem (Gal & Ghahramani, 2016). Dropout at test time approximates inference in a deep Gaussian process — a form of approximate Bayesian inference.

MC Dropout prediction: Run TT forward passes at test time with dropout active:

y^(x)=1Tt=1Tf(x;θ,m(t)),m(t)Bernoulli(1p)d.(4)\hat{y}(\mathbf{x}) = \frac{1}{T}\sum_{t=1}^T f(\mathbf{x}; \boldsymbol\theta, \mathbf{m}^{(t)}), \quad \mathbf{m}^{(t)} \sim \text{Bernoulli}(1-p)^d. \tag{4}

Uncertainty estimate:

Var[yx]1Tt=1Tf(x;m(t))2y^(x)2+τ1,(5)\text{Var}[y \mid \mathbf{x}] \approx \frac{1}{T}\sum_{t=1}^T f(\mathbf{x}; \mathbf{m}^{(t)})^2 - \hat{y}(\mathbf{x})^2 + \tau^{-1}, \tag{5}

where τ1\tau^{-1} is a model precision term related to weight decay.

Interpretation: The variance across dropout samples captures epistemic uncertainty — high variance indicates the model is unsure because different subnetworks disagree.


Dropout in Different Architectures

  • Fully connected layers: Standard dropout with p[0.2,0.5]p \in [0.2, 0.5].
  • Convolutional layers: Spatial dropout — drop entire feature maps rather than individual pixels. Standard dropout on individual pixels is too aggressive (adjacent pixels are correlated).
  • Recurrent layers: Apply to non-recurrent connections only (not hidden-to-hidden). Variational dropout: same mask across time steps.
  • Transformers: Applied to attention weights and after FFN layers. Typical p=0.1p = 0.1.

Common Pitfalls

Pitfall 1. Using dropout with batch normalization. BN estimates batch statistics; dropout changes the distribution. At test time, the BN running statistics are inconsistent with the non-dropped network. Use one or the other.

Pitfall 2. Applying dropout before the final layer without inverted scaling. The logits will be systematically lower at test time.

Pitfall 3. Setting pp too high. p>0.5p > 0.5 means most of the network is dropped — underfitting. For large models, p=0.1p = 0.10.30.3 is typical.


Summary

  • Dropout randomly zeros activations during training: h~=mh/(1p)\tilde{\mathbf{h}} = \mathbf{m} \odot \mathbf{h}/(1-p).
  • Acts as an implicit ensemble of 2d2^d subnetworks.
  • Prevents co-adaptation — neurons must be independently useful.
  • MC Dropout at test time provides uncertainty estimates (approximate Bayesian inference).
  • Apply dropout rates of 0.1–0.5 depending on model size and task.

Exercises

Exercise 1. Show that inverted dropout (equation 2) has E[h~]=h\mathbb{E}[\tilde{\mathbf{h}}] = \mathbf{h}.

Exercise 2. For a linear network y=wTh~y = \mathbf{w}^T\tilde{\mathbf{h}} with dropout, compute Var(y)\text{Var}(y) and show it provides an implicit L2 penalty on w\mathbf{w}.

Exercise 3. Prove that the number of possible subnetworks with dd droppable units is 2d2^d.

Exercise 4. Implement MC Dropout conceptually: for a classification problem, explain how to obtain predictive entropy from TT stochastic forward passes.

Exercise 5. Derive the equivalent weight decay strength λ\lambda corresponding to dropout rate pp for a single linear layer (Gal & Ghahramani, 2016).