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 net is not "more exact". It has memorised the noise, and noise does not repeat. The diagnostic is one extra column: the test score. If training score is high and test score is much less, the net is overfitting — it learned the training set's noise. If both scores are low, the net is underfitting — it cannot represent the pattern at all. The fixes are opposite: overfitting needs less capacity (less degree, more regularisation, more data, dropout), underfitting needs more capacity (more degree, more features, less regularisation). Applying the wrong fix makes things worse. And a single accuracy count cannot tell you which way to go. The bias-variance tradeoff is the theoretical frame: bias drives underfitting (the net cannot flex enough), variance drives overfitting (the net flexes too much). Learning curves — plotting both scores against training-set size — show whether more data will help (it closes an overfitting gap but cannot fix an underfitting plateau). This page fits polynomials of degree 1, 3. And 9 to the same noisy data, prints both scores. And shows the learning curves for each.
Adjust the Model Complexity and train the model for thousands of Epochs to see how it learns to memorize the training data.
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.
Fit ten data points that follow a gentle curve with a little noise on top.
The degree-9 net is not "more exact". It has memorised the noise, and noise does not repeat. The diagnostic is one extra column: the test score. If training score is high and test score is much less, the net is overfitting — it learned the training set's noise. If both scores are low, the net is underfitting — it cannot represent the pattern at all. The fixes are opposite: overfitting needs less capacity (less degree, more regularisation, more data, dropout), underfitting needs more capacity (more degree, more features, less regularisation). Applying the wrong fix makes things worse. And a single accuracy count cannot tell you which way to go. The bias-variance tradeoff is the theoretical frame: bias drives underfitting (the net cannot flex enough), variance drives overfitting (the net flexes too much). Learning curves — plotting both scores against training-set size — show whether more data will help (it closes an overfitting gap but cannot fix an underfitting plateau). This page fits polynomials of degree 1, 3. And 9 to the same noisy data, prints both scores. And shows the learning curves for each.
Expected error on unseen data splits into three parts:
error = bias² + variance + irreducible noise
Bias is error from wrong assumptions — a net 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 net flexible enough to fit noise. High variance is overfitting: excellent training performance, poor validation performance.Irreducible noise is the part no net can remove. If the same inputs sometimes give other 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 net sits where their sum is smallest, not where either is minimised.
The diagnosis needs just the training and validation loss, compared against each other and against what is achievable:
For overfitting, more data is the just 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 just then a less net, since shrinking capacity is the bluntest option.
For underfitting, first confirm the net is training at all — a learning rate that is too high or too low looks just like not enough capacity. Then widen or deepen the network, remove regularisation, train for longer. Or improve the features. A net 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 net too simple to capture the pattern. Training error is high, validation error is high. And the two are close. The net has not learned enough.
Overfitting is a net that learned the training data with its noise. Training error is very low, validation error is much more. And the gap is the symptom. The net learned too much of the wrong thing.
The diagnosis needs just two counts:
| 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 often means augmentation is applied just 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 net, 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 net stopped generalising and started memorising. And it is just where early stopping should trigger.
Validation noisy but not trending: normal. Judge the trend over a few epochs, not one.
A tied check: if training accuracy reaches 100%, the net has memorised the training set. That is not automatically bad — large networks often do this and still generalise — but the validation curve is the just thing that tells you which case you are in.
The net needs more capacity or better inputs.
The sanity check that settles it: try to overfit a tiny subset — 20 cases — deliberately. A correct net and training loop should reach near-zero loss on 20 cases 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 net 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 net 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 ways.
In rough order of effectiveness:
More data. The just 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 pic tasks with a few thousand cases.
Early stopping. Free, and it right targets the moment overfitting begins. Keep the best checkpoint, not the last.
Weight decay. Penalises large weights, pulling the net towards simpler solutions. Always worth having on.
Dropout. Standard in dense layers and transformers, less used in modern convolutional networks.
A less net. Effective and blunt. Try the regularisers first, since a less net also lowers the achievable ceiling.
Transfer learning. With a few hundred cases, fine-tuning a pretrained net beats training a less one from scratch by a wide margin.
Label smoothing and mixup. Soften the targets so the net 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 nets.
As net size grows, test error falls, then rises around the point where the net can just interpolate the training data. And then falls again as the net grows more still. Very large networks often generalise well despite fitting their training data perfectly. It classical theory did not predict.
Two real implications. Training accuracy of 100% is not by it evidence of a problem — look at validation. And with modern designs, "make the net less" is a less automatic response than it used to be. More data, augmentation and regularisation often 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 counts is the diagnosis.
Building on the same setup, the next block shows the left cases.
The next block covers the left steps.
The next block continues with the left demonstrations.
How big a train/validation gap is acceptable? There is no universal count. 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 net overfit and underfit at once? Yes — high bias and high variance together, often from a badly chosen net plus not enough data. Both errors are large and the gap is also large.
Does more data always help? With overfitting, yes. With underfitting, no — a linear net fitted to a million points is still linear.
Should I stop as soon as validation loss rises? Use patience — wait a few epochs, since validation loss is noisy and can dip and recover.
Is 100% training accuracy bad? Not necessarily, for large nets. The validation curve is the evidence that matters.
How do I know if it is a bug rather than underfitting? Try to overfit 20 cases. 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.
Move model complexity from too simple to too flexible and watch the gap open between training and validation performance.