Intermediate level · Module 3: CNN Training and Optimization · Lesson 2 of 3
Batch Normalisation, Dropout and Optimisers
Learners add batch normalisation and dropout, compare SGD with momentum and Adam, and use a learning-rate schedule.
In this lesson you will
- Add BatchNorm and dropout to a CNN
- Compare optimisers and use a learning-rate scheduler
Key concepts
nn.BatchNorm2dnn.DropoutSGD with momentumAdamlearning-rate schedulers
The lesson
Batch normalisation (nn.BatchNorm2d after a convolution) stabilises training and allows higher learning rates. Dropout randomly switches off units during training, which reduces overfitting. Remember model.train() and model.eval(): both layers behave differently during evaluation.
Adam adapts the step size for each parameter and usually works with little tuning. SGD with momentum often generalises well with a good learning-rate schedule. torch.optim.lr_scheduler.StepLR or CosineAnnealingLR lowers the learning rate during training.
Change one thing at a time and record the result; otherwise you cannot tell which change helped.
Step by step
- Add BatchNorm2d and dropout to the CNN.
- Train with Adam and with SGD plus momentum.
- Add a learning-rate scheduler to the better optimiser.
- Record validation accuracy for each change in a table.
Practice activity
Produce an ablation table showing the effect of each training change.
Expected result: A table with one change per row and clear effects on validation accuracy.
Check your understanding
-
Why call model.eval() before evaluating?
Show answer
BatchNorm and dropout behave differently during evaluation.
-
Why change one setting at a time?
Show answer
To know which change caused the effect.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.