Adjust the Model Complexity and train the model for thousands of Epochs to see how it learns to memorize the training data.
Fit ten data points that follow a gentle curve with a little noise on top.
The degree-9 model is not "more accurate". It has memorised the noise, and noise does not repeat.
Both failures look like poor performance and need opposite fixes. Telling them apart is a question of whether the model can even represent the pattern, or whether it has memorised the noise around it.
Expected error on unseen data splits into three parts:
error = bias² + variance + irreducible noise
Bias is error from wrong assumptions — a model too simple to represent the real relationship. High bias is underfitting, and it shows up as poor performance on training and validation data.Variance is sensitivity to the particular training sample — a model flexible enough to fit noise. High variance is overfitting: excellent training performance, poor validation performance.Irreducible noise is the part no model can remove. If the same inputs sometimes produce different outputs, no amount of capacity will fix it, and a validation loss that flattens above zero is often this rather than a failure.Capacity trades the first two against each other: adding it lowers bias and raises variance. The best model sits where their sum is smallest, not where either is minimised.
The diagnosis needs only the training and validation loss, compared against each other and against what is achievable:
For overfitting, more data is the only fix with no downside, and augmentation is the cheap approximation to it. After that: early stopping, which costs nothing; then dropout or weight decay; and only then a smaller model, since shrinking capacity is the bluntest option.
For underfitting, first confirm the model is training at all — a learning rate that is too high or too low looks exactly like insufficient capacity. Then widen or deepen the network, remove regularisation, train for longer, or improve the features. A model that cannot overfit a small subset of the training data has a bug, not a capacity problem, and that is the fastest test to run.
Underfitting is a model too simple to capture the pattern. Training error is high, validation error is high, and the two are similar. The model has not learned enough.
Overfitting is a model that learned the training data including its noise. Training error is very low, validation error is much higher, and the gap is the symptom. The model learned too much of the wrong thing.
The diagnosis needs only two numbers:
| Training error | Validation error | Diagnosis |
|---|---|---|
| High | High, similar | Underfitting |
| Low | Much higher | Overfitting |
| Low | Low, similar | A good fit |
| High | Lower than training | A bug or a leak |
That last row is worth naming: validation better than training usually means augmentation is applied only to training data, dropout is inflating training loss, or the split leaked.
Plot both losses against epochs and the shape tells you what is happening.
Both falling, still close: keep training.
Both flat and high from early on: underfitting. The model, the features or the learning rate is the problem.
Training falling, validation flattening then rising: the classic overfitting signature. The point where validation turns up is where the model stopped generalising and started memorising, and it is exactly where early stopping should trigger.
Validation noisy but not trending: normal. Judge the trend over several epochs, not one.
A related check: if training accuracy reaches 100%, the model has memorised the training set. That is not automatically bad — large networks often do this and still generalise — but the validation curve is the only thing that tells you which case you are in.
The model needs more capacity or better inputs.
The sanity check that settles it: try to overfit a tiny subset — 20 examples — deliberately. A correct model and training loop should reach near-zero loss on 20 examples within a few hundred steps. If it cannot, the problem is a bug, not capacity, and no amount of tuning will help.
They need opposite treatment, which is why diagnosing correctly matters more than any individual fix.
Treating overfitting by training less. Early stopping helps, but if a model overfits after two epochs the real problem is capacity against data volume, not epoch count.Adding data to fix underfitting. More data does not help a model that lacks the capacity to represent the pattern in the first place. It is the standard remedy for overfitting and close to useless for the opposite.
Too little capacity misses the signal; too much memorises the noise — and the cures point in opposite directions.
In rough order of effectiveness:
More data. The only fix that reduces variance without adding bias, and the reason "get more data" is such a reliable answer.
Data augmentation. Effectively more data, and often the single biggest improvement on image tasks with a few thousand examples.
Early stopping. Free, and it directly targets the moment overfitting begins. Keep the best checkpoint, not the last.
Weight decay. Penalises large weights, pulling the model towards simpler solutions. Always worth having on.
Dropout. Standard in dense layers and transformers, less used in modern convolutional networks.
A smaller model. Effective and blunt; try the regularisers first, since a smaller model also lowers the achievable ceiling.
Transfer learning. With a few hundred examples, fine-tuning a pretrained model beats training a smaller one from scratch by a wide margin.
Label smoothing and mixup. Soften the targets so the model is not pushed towards absolute confidence.
The classical picture — a U-shaped test error, with a sweet spot of complexity in the middle — is incomplete for very large models.
As model size grows, test error falls, then rises around the point where the model can exactly interpolate the training data, and then falls again as the model grows larger still. Very large networks often generalise well despite fitting their training data perfectly, which classical theory did not predict.
Two practical implications. Training accuracy of 100% is not by itself evidence of a problem — look at validation. And with modern architectures, "make the model smaller" is a less automatic response than it used to be; more data, augmentation and regularisation usually beat shrinking the network.
The classical U-curve is still real. It is now understood as the first half of a longer story.
Capacity swept from far too little to far too much, with train and test error side by side. The two failures are opposite ends of one axis, and the gap between the two numbers is the diagnosis.
How big a train/validation gap is acceptable? There is no universal number. What matters is whether validation performance is good enough and stable. A 2% gap on a hard task may be fine; a 30% gap rarely is.
Can a model overfit and underfit at once? Yes — high bias and high variance together, usually from a badly chosen model plus insufficient data. Both errors are large and the gap is also large.
Does more data always help? With overfitting, yes. With underfitting, no — a linear model fitted to a million points is still linear.
Should I stop as soon as validation loss rises? Use patience — wait several epochs, since validation loss is noisy and can dip and recover.
Is 100% training accuracy bad? Not necessarily, for large models. The validation curve is the evidence that matters.
How do I know if it is a bug rather than underfitting? Try to overfit 20 examples. If you cannot, it is a bug.
Answer without scrolling back up.
Training accuracy 99%, validation accuracy 62%. This is:
The model has learned the training set specifically, including its noise, and cannot generalise. A large gap between the two scores is the tell.
Training accuracy 61%, validation accuracy 60%. This is:
Both scores are poor and close together, so nothing is being memorised - there simply is not enough capacity, or enough training, to capture the pattern.
Which change would you expect to reduce overfitting?
More data makes memorisation harder and generalisation easier. The other three all push capacity or fitting further in the direction that caused the problem.
Both failures look like poor performance and need opposite fixes. Telling them apart is a question of whether the model can even represent the pattern, or whether it has memorised the noise around it.