3.2.10 · D3Training Deep Networks

Worked examples — Dropout regularization

2,232 words10 min readBack to topic

This deep dive drills the arithmetic of dropout until no case can surprise you. The parent note built the ideas; here we exhaust the numbers. Before we compute anything, let us name every symbol so nothing appears unearned.


The scenario matrix

Every question dropout can throw at you falls into one of these cells. The examples below are labelled by which cell they hit, and together they cover all of them.

Cell Scenario class What could go wrong
A Standard train-time mask + rescale forgetting the boost
B Test-time forward pass accidentally masking at test
C Extreme : (keep all) scale factor , dropout vanishes
D Extreme : (drop all) division by blows up
E Degenerate mask: all-drop / all-keep sample a single unlucky step
F Expectation over many masks proving the average is preserved
G Original (non-inverted) convention scale DOWN at test by
H Real-world word problem choosing , reading a framework
I Exam twist: variance, not just mean dropout changes spread, not average
J Ensemble counting ( subnets) miscounting sub-networks

Figure — Dropout regularization

The figure above shows Cell A happening: raw bulbs on the left, a random on/off mask in the middle, and the boosted survivors on the right. Keep it in view for Example 1.


Example 1 — Cell A: standard train-time step

Forecast: guess before reading — will the surviving numbers be bigger or smaller than and ?

  1. Apply the mask. . Why this step? literally switches a bulb off; multiplication by is how "off" is encoded.
  2. Rescale survivors by . . Why this step? On average only half the bulbs survive, so each survivor must shine twice as bright to keep the layer's total expected signal unchanged.

Verify: expected value of position 1 over all masks ✅ (matches original). The survivors got bigger — forecast confirmed.


Example 2 — Cell B: the test-time pass

Forecast: more zeros? Bigger numbers? Or exactly ?

  1. No mask at test. With inverted dropout, test uses . Why this step? All the scaling was already paid during training (the boost), so inference is a plain deterministic forward pass.
  2. Output: . Why this step? Every bulb is on; no random exists at test.

Verify: the average train output at each position was also (Example 1's check). Train-average equals test value no distribution shift. ✅


Example 3 — Cell C: the limit

Forecast: does the boost matter here?

  1. Scale factor: . Why this step? Almost all bulbs survive, so the correction is tiny.
  2. Apply: .
  3. Limit: as , , , so . Dropout disappears. Why this step? If you never drop anyone, there is nothing to correct — regularization strength goes to zero.

Verify: and . ✅


Example 4 — Cell D: the limit

Forecast: what does do as shrinks toward ?

  1. Scale factor: . Why this step? Almost every bulb is off, so the rare survivor must be boosted enormously to represent the whole layer.
  2. A surviving neuron at value becomes — a huge, noisy spike. Why this step? One survivor now carries the signal of the entire layer, so its rescaled value explodes.
  3. At exactly : , and is division by zero — undefined. Also every bulb is off, so there is literally no signal. Why this step? The formula and the concept both break; you must keep .

Verify: exactly, and makes undefined. ✅


Example 5 — Cell E: an unlucky degenerate sample

Forecast: how likely is each, and is either "wrong"?

  1. All dropped: . Probability . Why this step? Each independent bulb is off with prob ; all four off .
  2. All kept: . Probability . Why this step? All four on ; survivors doubled by .
  3. Interpretation: neither single step is "wrong" — dropout is deliberately noisy. Correctness lives in the average, not any one sample.

Verify: for both. ✅


Example 6 — Cell F: expectation over many masks

Forecast: will the average land above, below, or exactly on ?

  1. One position's expectation: . Why this step? and are constants; only is random, so pull constants out.
  2. Insert (Bernoulli mean): . Why this step? This is the whole point of the factor — it exactly cancels the shrink.
  3. Vector result: .

Verify (numeric simulation intent): for position with , average . ✅ Forecast: exactly on .


Example 7 — Cell G: original (non-inverted) convention

Forecast: which convention puts the extra work at test time?

  1. Train (no scale): . Why this step? Original dropout leaves survivors at raw brightness during training.
  2. Test (scale down by ): . Why this step? At test all bulbs are on, so their raw sum is too big; multiply by to shrink back to training scale.

Verify: train-time expected survivor value ; test value . Both equal ⇒ matched. For : . ✅ (Inverted moves the work to train; original moves it to test.)


Example 8 — Cell H: real-world word problem

Forecast: is p closer to or ?

  1. Keep fraction wanted: . Why this step? Expected active units , so is the target keep fraction.
  2. Convert to PyTorch p: . Why this step? PyTorch's nn.Dropout(p) treats p as drop probability (a classic trap — see the parent's mistakes).
  3. Expected active units: . Why this step? Sum of independent Bernoulli() keeps has mean .

Verify: , and . ✅ Forecast: closer to .


Example 9 — Cell I: exam twist (variance, not mean)

Forecast: is the variance zero (mean is preserved!) or positive?

  1. Possible values: with prob , or with prob . Why this step? is either (survive, boosted to ) or (dropped to ).
  2. Mean: (matches, good).
  3. Variance . Here . Why this step? Variance measures spread; we need the average of squares minus square of average.
  4. Result: . Why this step? This positive spread is the regularizing noise — the mean stays honest while the signal jitters.

Verify: . General formula: . ✅ Forecast: positive.


Example 10 — Cell J: counting the ensemble

Forecast: does adding one unit add or double the sub-network count?

  1. Each unit is a switch with states (on/off), chosen independently. Why this step? A sub-network is fully described by which units are on; that's a length- binary string.
  2. Total configurations . For : . For : . Why this step? Independent binary choices multiply: ( times).
  3. Ensemble link: dropout trains one random member of this -family per step; test-time weight-sharing approximates averaging all of them — a free bagging ensemble.

Verify: , ; adding one unit doubles the count (). ✅ Forecast: doubles.



Active Recall

Connections

  • 3.2.10 Dropout regularization (Hinglish) — the parent topic these examples drill.
  • Bernoulli Distribution — every mask entry is Bernoulli(); its mean drives all the arithmetic here.
  • Overfitting and Generalization — Example 8's word problem is exactly closing the generalization gap.
  • Ensemble Methods (Bagging) — the count of Example 10.
  • Bias-Variance Tradeoff — the added variance of Example 9 is the price paid for lower variance in the final model.
  • L2 Regularization (Weight Decay) — an alternative regularizer to compare scale choices against.
  • Batch Normalization — often reduces how aggressive needs to be.

Scenario Map

Standard train step scale 1 over q

Test time full network

p to 0 dropout vanishes

p to 1 divide by zero

Unlucky all drop or all keep

Expectation equals a

Original convention scale at test

Word problem choose p

Variance is the noise

Count 2 to the n subnets

Dropout scenario matrix