Map 1 · Building and training a network · Step 9
Regularise
How do I close the gap between training and validation?
Key formula
Fact or figure
Inverted dropout scales the kept units by in training, so nothing changes at test time.
Skip this step and…
Forgetting model.eval() leaves dropout on during evaluation, giving noisy, worse results.
Digits example
Small shifts and rotations of each digit as augmentation (never 180°, which turns a 6 into a 9), dropout before the output layer, early stopping.
Learn it
Taught in Section 9 (Regularisation) of the course. The map follows the deep learning workflow, the order you build a model in; the course teaches in the order that is easiest to learn, so the numbers can jump.
- 9.1 L2 and L1 PenaltiesAdd a penalty on the size of the weights to the loss. L2 gives weight decay: every step shrinks the weights a little. L1 pushes small weights to exactly zero. The derivation and the difference.
- 9.2 Early StoppingWatch the validation cost every epoch, keep the best weights, and stop when it stops improving. Why it regularises, and the patience setting.
- 9.3 DropoutRandomly switch off hidden units during training. Inverted dropout as lectured: drop with probability p, scale the survivors by 1/(1−p), change nothing at test time. Why it prevents co-adaptation and how to use it in PyTorch.
- 9.4 Data AugmentationWhen you can't collect more data, make more from what you have: transformed copies that keep the right label. Which transformations suit images, audio and tabular data, and which ones break the label.
How it connects
Feeds into · Step 2
Prepare the dataData augmentation creates new training examples from the data you already have
How do I split, scale and encode the data?
Feeds into · Step 7
Update the weightsWeight decay changes the update rule, and early stopping decides when training stops
How do I turn gradients into a better network?
Builds on · Dense lane · step M3
Size the networkLarge networks need regularising
How deep, how wide, and for which task?
Builds on · Step 8
Evaluate honestlyA train–validation gap calls for regularisation
Is it learning, or memorising?