Deep Learning · Deep Learning
Training Loop
In Deep Learning because loss, backprop and epochs are how neural parameters are trained.
Training is repeated predict → loss → update.
- Deep Learning
- Medium level
- 4 concepts
1The loop
Each step computes predictions, a scalar loss, and an update to parameters.
Minibatches keep memory bounded — stay under a few dozen samples per batch here.

Why must the loss be a single scalar rather than one number per training example?
- A gradient is taken of one quantity, so the per-example errors have to be reduced to one before the backward pass can run
- The framework has no way to store more than one number at a time
- A minibatch always contains exactly one example
- Scalar losses simply train faster than vector losses
Every parameter needs one derivative saying which way to move. That only exists once the batch has been collapsed into a single objective, usually by taking the mean.
2Epochs versus steps
An epoch is one pass over the training set; a step is one minibatch update.
Report both when you describe a run — "5 epochs" alone hides batch size.
Figure. An epoch is one pass over the training set. A step is one minibatch update. Report both — saying 5 epochs alone hides batch size.
Two runs both report '5 epochs'. One performed 50 updates and the other 5000. What differed?
- The batch size: smaller batches mean many more updates over the same pass through the data
- The learning rate used for each update
- The number of layers in the network
- Whether the data was shuffled between passes
An epoch counts passes over the data and a step counts updates, and the batch size is the exchange rate between them. Quoting one without the other hides how much training happened.
3Backprop intuition
Backpropagation applies the chain rule so each weight knows its local contribution to loss.
You rarely hand-code it; frameworks do — you still must understand vanishing gradients.
Figure. Backpropagation applies the chain rule so each weight knows its local contribution to loss. Frameworks compute it; you still have to understand vanishing gradients.
The early layers of a deep net barely move while the last layer trains fine. Which property of backpropagation explains it?
- The gradient reaching an early layer is a product of many factors, and a product of small factors shrinks toward nothing
- Early layers hold fewer parameters, so they need fewer updates
- The optimizer updates layers in order and runs out of steps
- Early layers are frozen by default in most frameworks
The chain rule multiplies a factor per layer on the way back. Where those factors sit below one — a saturated sigmoid, say — the signal decays exponentially with depth.
4Early stopping
Stop when validation loss stops improving — a simple regulariser.
On tiny labs, prefer fewer epochs over heroic training times.
Figure. Training loss falls for as long as you keep going - it is fit to the data the model sees. Validation loss falls only while the model is still learning something general, then turns back up as memorisation starts. The marked minimum is the early stop: quit there and the extra epochs to the right, where only the train curve improves, are never paid for.
Early stopping watches the validation loss rather than the training loss. Why not the training loss?
- Training loss usually keeps falling while the model is getting worse on new data, so it can never be the thing that tells you to stop
- Training loss is noisier and therefore harder to read
- Training loss is not computed during an ordinary loop
- Validation loss falls faster, so it reaches its floor sooner
The signal you need is the turn from learning to memorising, and by construction the training loss cannot show it. Only data outside the fit changes direction.
Notes
- Loss, backprop intuition, epochs and overfitting.
- Each step computes predictions, a scalar loss, and an update to parameters.
- An epoch is one pass over the training set; a step is one minibatch update.
Exam traps & shortcuts
- Keep lab datasets under 2000 rows in the browser runtime.
- Split train and test before fitting any model that sees labels.
Recap
This lesson in brief:
- The loop
- Each step computes predictions, a scalar loss, and an update to parameters.
- Epochs versus steps
- An epoch is one pass over the training set; a step is one minibatch update.
- Backprop intuition
- Backpropagation applies the chain rule so each weight knows its local contribution to loss.
- Early stopping
- Stop when validation loss stops improving — a simple regulariser.
Practise Training Loop
Reading is free and needs no account. Practice, mocks and progress live in the app.
- A 1-question practice set that ends the chapter
- 4 quick checks with worked explanations
- Timed mocks scored with the real marking scheme
- Readiness tracked per topic, kept on your device