The idea
Modern networks have enough parameters to memorize their training sets outright, so generalization comes from constraining how they fit — regularization. The deep-learning toolkit has one method with a genuinely novel mechanism (dropout), plus classical tools carried over.
Dropout. During training, each unit is independently zeroed with probability ; survivors are scaled by (this is inverted dropout, what every framework implements). Formally, with mask entries :
The expectation is preserved, so at test time you simply switch dropout off and run a normal forward pass. Why it works, two complementary stories: (1) no co-adaptation — a unit cannot depend on a specific other unit existing, so features become individually useful and redundant; (2) implicit ensemble — every mask is a different subnetwork with shared weights, and the test-time network approximates averaging exponentially many of them.
The rest of the toolkit: weight decay (penalize ; use AdamW so it is not mangled by adaptive scaling), early stopping (halt when validation loss turns; free and always on), data augmentation (label-preserving transforms — the highest-leverage option for images and audio), and label smoothing (soften the one-hot target to for the correct class — at , — and for each wrong class; discourages overconfident logits).
Batch/layer normalization sit adjacent: they exist to stabilize optimization, not to regularize, but BN's minibatch noise has a mild regularizing side effect, and their mechanics are tested in the same interviews — key facts in the cheat sheet.
Worked example
A hidden layer outputs with dropout . One training step draws mask :
Surviving units are doubled; dropped units contribute nothing (and get no gradient this step — the mask gates the backward pass identically). The next minibatch draws a fresh mask, say , giving : a different subnetwork now takes the gradient step, though it shares every weight with the first. Training is effectively a lottery over subnetworks of this layer — that is the ensemble picture in miniature.
Check the expectation for the first unit across the mask distribution: it survives with probability at value , else — expected value , exactly the original activation. Downstream weights therefore see the same average input during training as they will at test time, when the layer just emits untouched. Without the scaling, training-time activations would average half the test-time ones, and the network would arrive at inference systematically miscalibrated.
Cheat sheet
Dropout
- Train: zero with prob , scale survivors by . Test: no-op.
- Typical : 0.5 classic dense heads; 0.1-0.3 modern nets; 0.1 in transformers (attention, FFN, embeddings).
- Skip it on: conv trunks (use BN + augmentation), right before BN, output layers.
- Nonstandard uses: MC dropout at test time = cheap uncertainty estimates.
Norm layers (the facts interviews want)
| Batch norm | Layer norm | |
|---|---|---|
| Normalizes over | batch, per channel | features, per example |
| Formula core | , then | same, with per-example |
| Train vs eval | different (batch stats vs running stats) | identical |
| Small/variable batches | breaks below ~8 | unaffected |
| Home turf | convnets | transformers, RNNs |
- BN classic bug: eval in train mode (or vice versa) → metrics nonsense; check
model.eval()first. - BN regularizes mildly via batch-stat noise; do not count it as your regularizer.
Other regularizers
- Weight decay: AdamW - (transformers), scale for SGD vision recipes.
- Early stopping: monitor val loss, patience a few evals; cheapest win available.
- Augmentation: images — flips/crops/color/mixup; text — harder, use paraphrase/backtranslation sparingly.
- Label smoothing: standard for classification.
Symptom → move: big train/val gap → augment + early stop + decay + dropout, in that order; train accuracy also low → you have a bias problem, regularizing makes it worse.