Map 1 · Building and training a network · Step 7
Update the weights
How do I turn gradients into a better network?
Key formula
on mini-batches; momentum or Adam in practice.
Fact or figure
An oscillating or exploding loss means is too large; a crawling one, too small. Search it on a log scale.
Skip this step and…
Forgetting optimizer.zero_grad() sums old gradients into every step.
Digits example
Mini-batches of 64 images: about 940 updates per epoch on 60,000 training images.
Learn it
Taught in Section 1 (Foundations of Deep Learning), Section 7 (Backpropagation), Section 8 (Generalisation and Data) and Section 11 (Network Design and PyTorch) 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.
- 1.3 Gradient Descent and MomentumTraining means minimising an objective. Gradient descent repeatedly steps against the gradient. A worked example, what the learning rate does, why a zero gradient is not proof of a minimum, and how momentum helps.
- 7.6 Mini-batches and Gradient CheckingHow often to update: online, full-batch and mini-batch gradient descent compared. And how to test a hand-written gradient with central finite differences before trusting it.
- 8.5 Hyperparameters and a Training RecipeWhat hyperparameters are, how to search them, how to read a learning rate from the loss curve, and a seven-step procedure for training a network that works.
- 11.3 Neural Networks in PyTorchDefine a network, choose a loss and optimiser, and write the training loop. A 100 → 50 → 10 classifier line by line, the logits rule, train and eval modes, and a custom activation function.
How it connects
Feeds into · Step 8
Evaluate honestlyTraining progress means little until it is measured on held-out data
Is it learning, or memorising?
Builds on · Step 6
Compute the gradientsThe gradients feed the weight update
How does each weight learn its share of the blame?
Builds on · Step 9
RegulariseWeight decay changes the update rule, and early stopping decides when training stops
How do I close the gap between training and validation?