← Explainer Library

Interactive Explainer

Dropout Playground

Slide the drop probability $p$ and watch a small network flicker. Every forward pass silences a different random subset of hidden units, so every pass is a different sub-network. Over many passes you are training an exponential ensemble with shared weights — the core intuition behind the most influential regularizer of 2012.

The Idea

Silence neurons at random

Dropout was Hinton's 2012 trick: on every training forward pass, randomly set a fraction of the hidden activations to zero. A unit survives with keep probability $1-p$ and is dropped with probability $p$. Write the per-unit switch as a Bernoulli variable $m_i$ and the dropped activation as $\tilde h_i$:

$$\tilde h_i = \frac{m_i}{\,1-p\,}\; h_i, \qquad m_i \sim \mathrm{Bernoulli}(1-p).$$

Two things are happening at once. The mask $m_i$ zeroes out a random subset of units. The factor $\tfrac{1}{1-p}$ rescales the survivors so the layer's expected output does not change — this is the "inverted dropout" convention PyTorch and every modern framework use, and it is exactly why the test-time path can be the plain identity. Play with both effects below.

The Lab

One mask per forward pass

A tiny MLP: four inputs, ten hidden units, one output. The hidden activations $h_i$ are fixed (the weights don't change here) — only the dropout mask is resampled. In train mode each surviving unit is scaled by $\tfrac{1}{1-p}$; dropped units and their edges grey out. In eval mode dropout is off: all units fire, nothing is scaled.

Mode

Numbers on the hidden nodes are the post-dropout activations ˜hi. Survivors carry the ×1/(1−p) boost; dropped units read 0.

Units kept
Scale 1/(1−p)
Output y (this pass)
Eval output y*
Mean over N passes
Try this. Set $p = 0.5$ and hit Auto. Each frame is a different thinned network, and the per-pass output (blue dots) scatters around the eval output (green line). Watch the running mean (orange) settle onto the green line: inverted scaling keeps the expected output constant, mask after mask. Now push $p$ toward $0.9$ — the survivors get scaled up by 10×, individual passes swing wildly, but the mean still homes in on $y^{*}$. Flip to Eval and the flicker stops: one deterministic answer.
The Payoff

Why the 1/(1−p) rescale?

Without rescaling, a layer that keeps only a fraction $1-p$ of its units at train time would fire much weaker than the full layer at test time — the distributions the next layer sees would not match. Inverted dropout fixes this by construction. Because $\mathbb{E}[m_i] = 1-p$,

$$\mathbb{E}[\tilde h_i] \;=\; \frac{h_i}{1-p}\,\mathbb{E}[m_i] \;=\; \frac{h_i}{1-p}\,(1-p) \;=\; h_i,$$

so the expected activation is unchanged, and therefore the expected output is exactly the deterministic eval output:

$$\mathbb{E}\!\left[\sum_i v_i\,\tilde h_i\right] \;=\; \sum_i v_i\,\mathbb{E}[\tilde h_i] \;=\; \sum_i v_i\,h_i \;=\; y^{*}.$$

That equality is what the orange running-mean line demonstrates above. The price you pay is variance — a single masked pass is a noisy estimate of $y^{*}$, and the noise grows sharply as $p \to 1$:

$$\mathrm{Var}[\tilde h_i] \;=\; h_i^{2}\,\frac{p}{1-p}.$$
Common bug. Forgetting model.eval() at inference leaves dropout on: predictions flicker between runs and probability calibration breaks. The mirror-image bug is calling model.train() but never zeroing gradients — different failure, same "why is my model random?" symptom.
Two Intuitions

Why silencing neurons regularizes

The ensemble view

A hidden layer of $N$ units has $2^{N}$ possible on/off masks. Each minibatch trains one randomly-drawn thinned network, but all of them share the same weights. Over training you are implicitly fitting an exponential ensemble for the price of a single model. At test time you drop the mask and use the full network, which approximates the geometric-mean prediction of that whole ensemble — ensembling for free.

The co-adaptation view

Without dropout, unit $j$ can learn to lean on unit $k$ always being present — a brittle conspiracy that fits training noise. Since any teammate might vanish on the next pass, dropout forces each unit to be useful on its own and spreads the representation across many units instead of a fragile few. The result is a smoother function that generalizes better.

In Practice

Where dropout lives in 2026

Variants worth knowing

MC dropout — dropout for uncertainty

Gal & Ghahramani (2016) showed that leaving dropout on at inference turns a deterministic net into an approximate Bayesian one: each masked pass is a sample from a posterior. Run $K$ forward passes and the spread of predictions is a cheap uncertainty estimate — exactly the blue-dot scatter above, now read as a posterior rather than as noise to average away.

It is cheap and easy, but MC-dropout uncertainties are usually under-confident and rarely beat deep ensembles. Treat it as a baseline; reach for ensembles when calibration matters, and pair either with temperature scaling or conformal prediction for confidence you can actually act on.

Reading list.

Srivastava, Hinton, Krizhevsky, Sutskever & Salakhutdinov (2014) — Dropout: A Simple Way to Prevent Neural Networks from Overfitting.

Wan et al. (2013) — Regularization of Neural Networks using DropConnect. · Huang et al. (2016) — Deep Networks with Stochastic Depth.

Gal & Ghahramani (2016) — Dropout as a Bayesian Approximation. · Ghiasi, Lin & Le (2018) — DropBlock.