Lesson 8: Reading Training Curves and Debugging a Model
Training a network produces numbers, but numbers alone do not tell you what is wrong. The training curve — a plot of loss against time, for both the training set and the validation set — is the first thing an experienced practitioner looks at, because its shape diagnoses the problem. Learning to read that shape is one of the most useful skills in this course.
A healthy curve looks like this: both losses fall quickly at first, then more slowly, and they stay close together. The training loss ends up a little lower than the validation loss, which is normal — the model has seen the training examples and not the validation ones. When you see this shape, training is working and your main job is patience: let it run, and stop when the validation loss stops improving.
Four Shapes, Four Diagnoses
If both losses stay high and barely move, the model is underfitting: it cannot even fit the training data. The usual causes are a learning rate that is far too small, a network that is too small, or a bug in the data — for example labels shuffled or inputs not scaled. The fix is to check the data first, then increase the learning rate or the model's size, and confirm on a tiny subset that the model can overfit it when asked to.
If the training loss falls but the validation loss rises, you have overfitting, from the previous lessons: stop earlier, add data, or regularise. If the loss jumps up and down wildly, the learning rate is probably too large — the steps are overshooting — so reduce it. And if the loss suddenly becomes not-a-number, something has gone badly wrong, usually a learning rate so large that the weights exploded; reduce it sharply and restart.
A Debugging Checklist
When a model misbehaves, work through a checklist instead of guessing. First, check the data: are the labels right, are the inputs the shape you expect, is anything missing? Second, try to overfit a single small batch — a healthy model should be able to memorise a few dozen examples, and if it cannot, something is broken in the model or the loss. Third, look at the learning rate: try a much smaller one and a much larger one and see which direction helps. Fourth, simplify: fewer layers, fewer features, a smaller problem. A simple model that works beats a large one that does not, and it tells you where the problem lies.
Finally, keep notes. Write down the learning rate, batch size, architecture and the resulting curves for every run, even the failed ones. Debugging a network is detective work, and the notes are the case file. The practitioners who improve fastest are rarely the ones with the cleverest ideas; they are the ones who change one thing at a time and remember what happened.
When the Curves Lie
Training curves can mislead as well as inform, and the most common trap is a validation set that is too small. With only fifty validation examples, each one is worth two percentage points, so the validation loss jumps around by chance and a single lucky run can look like a breakthrough. The remedy is a validation set large enough that its noise is smaller than the differences you care about — a few hundred examples at least — and a habit of not overreacting to a single epoch's result. Look at the trend over several epochs, not the value at one point.
A second trap is a validation set that is too similar to the training set. If the same person's handwriting appears in both, or if near-duplicate images are split across the two sets, the validation score will flatter the model, because it has effectively seen the test already. The fix is to split by group — by person, by source, by date — so that the validation set is genuinely new. This is called a grouped split, and it is the honest version of the random split. Whenever a validation score looks surprisingly good, ask how the split was made before celebrating.
Watch & Learn
One video to watch for this unit, from a trusted educator.
- Gradient descent, how neural networks learn | Deep Learning Chapter 2 — 3Blue1Brown
The cost function, the gradient and the downhill walk — the ideas behind this unit's training curves, shown visually.
Key Terms
- Training curve
- A plot of loss against training time, usually for both training and validation sets.
- Underfitting
- When a model cannot even fit its training data, so both losses stay high.
- Overfitting
- When training loss falls but validation loss rises: the model memorises instead of learning.
- Not-a-number (NaN)
- An invalid loss value, often caused by a learning rate so large that weights explode.
- Sanity check
- A small test, such as overfitting one batch, that confirms the model and pipeline basically work.
- Learning-rate sweep
- Trying several learning rates in turn to find which range trains well.
Discussion Questions
- Both losses are high and flat. Why is checking the data a better first step than making the network bigger?
- A model overfits a single batch easily but fails on the full dataset. What does that tell you about the model versus the data?
- Why is changing one thing at a time so important when debugging? What goes wrong if you change three?
Practice Questions
- Training loss falls steadily but validation loss rises. What is the diagnosis?
- Both losses stay high and barely move. What is the most likely diagnosis?
- The loss jumps wildly up and down from step to step. What should you try first?
- What is the point of trying to overfit a single small batch?
- Why should you keep notes on every training run, including failed ones?
Show answers
- Overfitting. The model is memorising the training data instead of learning a pattern that generalises.
- Underfitting. The model cannot fit even the training data — check the data, the learning rate, and whether the model is big enough.
- Reduce the learning rate. Wild jumps usually mean the steps are overshooting the valley.
- It is a sanity check: a healthy model should be able to memorise a few dozen examples. If it cannot, something is broken in the model, the loss, or the data.
- So you can compare runs, avoid repeating failures, and work out which change actually helped. Debugging is detective work and the notes are the case file.