Overfitting

Overfitting is when a model learns its training data, noise and quirks included, so closely that it scores well on that data and clearly worse on new data it has not seen. In Supervisely, training apps show losses and metrics every epoch, and the evaluation report scores the model on the validation set.

Tasks and training

How it shows up in training curves

Training loss keeps falling while validation loss flattens and then rises. Validation mAP or IoU peaks and starts to slide while training metrics still improve. The epoch at that peak is roughly where the model stopped learning general patterns and started memorizing specific images.

Usual causes

  • Too little data for the size of the model, or too little variety: one camera, one site, one season.
  • Training for many more epochs than the data supports.
  • Rare classes with a handful of examples, which the model can learn by heart.
  • Label noise that the model fits as if it were signal.

What helps

  • More and more varied data, and data augmentation to stretch what you have.
  • Starting from a pretrained checkpoint instead of random weights, see transfer learning.
  • Keeping the checkpoint with the best validation score rather than the last one.
  • Regularization such as weight decay or dropout, or a smaller model.

The trap that hides it: a leaky validation split

If consecutive frames of one video, or near-duplicate photos of one object, land in both training and validation, validation scores stay high even when the model is memorizing. Split by video, scene, site or date, not by individual image, and the validation curve will tell the truth.

Catching it in Supervisely

The training apps behind model training let you set the train and validation split before a run and show losses and metrics every epoch, with TensorBoard a click away. When the run ends, the evaluation report scores the model on the validation set, and comparing two experiments side by side shows whether a longer run actually helped.

Frequently asked questions.

What is the difference between overfitting and underfitting?

An overfit model does well on its training data and clearly worse on new data, because it learned the noise along with the patterns. An underfit model does poorly on both, because it is too small, trained too briefly or given features that cannot explain the labels.

Is 98% accuracy a sign of overfitting?

Not by itself. Overfitting shows in the gap between training and validation scores, not in one high number. 98% on a validation set kept apart by video, scene or site is a good result; 98% on training data with 80% on validation is overfitting.

Is it better to overfit or underfit?

Neither, but slight overfitting is easier to fix: add data or augmentation, regularize or stop training earlier. An underfit model needs more capacity or more training.