§7.12aDropout, Part 1 — Bagging Exponentially Many Networks

Part II DL pp. 258–262 · ~3 min read

  • dropout
  • dropout mask

§7.12 Dropout — bagging made practical

Bagging (§7.11) is powerful, but training and evaluating many large neural networks is expensive. Dropout is the trick that makes it practical: to a first approximation, it is bagging over an ensemble of exponentially many networks, at almost no extra cost. The ensemble consists of every sub-network you can form by removing non-output units from a base network — and removing a unit just means multiplying its output by zero.

A base net with 2 inputs and 2 hidden units has 24=162^4 = 16 such sub-networks. Resample the mask to visit them, or view the whole ensemble (fig 7.6):

Fig 7.6/7.7 (interactive) — dropout samples a binary mask µ over the non-output units, training whichever sub-network survives; the output unit is never dropped
x₁x₂h₁h₂y
µ = [1, 1, 1, 0]  (x₁ x₂ h₁ h₂)
step 1 · 4 of 5 units active

Each minibatch example multiplies every input/hidden unit by an independent 0/1 mask (keep-prob 0.8 input, 0.5 hidden), then runs the usual forward/backward pass on the surviving sub-network. The output unit is never dropped. Over training we visit an exponential number of these networks — all sharing one set of weights.

The procedure rides on top of ordinary minibatch SGD. Each time an example enters a minibatch, sample a fresh binary mask µ\boldsymbol{µ} — one entry per input and hidden unit, each drawn independently with a fixed keep-probability (typically 0.8 for inputs, 0.5 for hidden units) — multiply every unit by its mask entry, and run the usual forward propagation, back-propagation, and update on the surviving sub-network. Formally, dropout minimizes the expected cost over masks:

Term by term

minimizeEµJ(θ,µ)\text{minimize} \quad \mathbb{E}_{\boldsymbol{µ}}\, J(\boldsymbol{\theta}, \boldsymbol{µ})
µ\boldsymbol{µ}the binary mask: which units are kept this step, each sampled independently with its keep-probabilitythe mask
J(θ,µ)J(\boldsymbol{\theta}, \boldsymbol{µ})the cost of the single sub-network selected by θ and µone sub-net cost
Eµ[]\mathbb{E}_{\boldsymbol{µ}}[\cdot]the average over ALL masks — exponentially many terms, but drawing one µ per step gives an UNBIASED estimate of the gradientthe ensemble

Why an exponential ensemble is affordable

The exponential term count looks hopeless, but two things save it. First, we never sum over all masks — we sample one per example, and the stochastic gradient is unbiased. Second, all the sub-networks share one set of weights: each is just the parent net with some units switched off, so the entire ensemble costs the same memory as a single network. Dropout adds only the cost of generating the mask.

How dropout differs from true bagging

Dropout is bagging with two twists — parameter sharing, and the fact that almost no member is ever trained on its own:

Dropout vs. ordinary bagging
baggingdropout
parameterseach model has its OWN independent parametersall sub-networks SHARE parameters — each inherits a subset from the parent net
trainingeach model is trained to convergence on its datasetmost sub-networks are never explicitly trained; a tiny fraction each take one step, and parameter sharing propagates good settings to the rest
data per membera dataset resampled with replacementthe same — each sub-network sees a subset of the training set (its minibatch examples)
Dotted-underlined cells have explanations — click one.

There are far too many sub-networks to sample in the lifetime of the universe, so most are never touched directly — yet because they share weights, training a sliver of the ensemble tunes them all. That is the whole trick.

Next: how to make a prediction from this ensemble in a single forward pass — the weight-scaling inference rule — plus adversarial training — dropout part 2 & adversarial training.

Check yourself — dropout as bagging

1.What ensemble does dropout train, and how is a sub-network formed?

2.In DropoutLab, click 'show all 16'. Why are there exactly 16 sub-networks, and why is the output unit never among the dropped ones?

3.How is the dropout objective E_µ J(θ,µ) optimized despite having exponentially many terms?

4.What are the two key ways dropout differs from ordinary bagging?

5.Why does dropout cost roughly the same memory as a single network, despite representing an exponential ensemble?

5 questions