Concepts / Interpreting Training Curves

Interpreting Training Curves

A healthy plot has two properties at once: a clear downward trajectory, and a validation line that tracks the training line. Missing either one is a reason to look more closely.

  • Programming

Why One Final Number Is Not Enough

When a model is fine-tuned, its loss is recorded again and again during training, and also on a held-out validation set. A single final number cannot tell you how that process unfolded. A plot can. It shows whether the loss fell quickly, leveled off, or moved in a direction you did not expect, and it lets you compare the behavior on the training data with the behavior on data the model never trained on.

In this article you will look at a small plotting routine and then work backward through each part of it. The goal is to be able to look at the resulting picture and say, with specific reasons, whether the run went well and, if it did not, which part of the pipeline you would inspect.

Following the Two Loss Lists

A loss curve is a record of how far the model's predictions are from the correct answers at each point in training. Plotting it against epochs puts the training history on a horizontal scale that counts full passes through the training data. The training loss is measured on data the model is learning from. The validation loss is measured on data held back from training, so it indicates how the model behaves on material it has not been fitted to.

Training lossData the model learns fromValidation lossData held back fromtrainingShape: falls thenflattensSharp drop early in the runShape: followstraining lineSame overall movementshape ofshape of
What does each line measure, and how do the two lines relate to each other on the same epoch axis?

Both lines are drawn from their own list of values and share the epoch axis. Neither line is computed from the other. That independence is what makes the comparison meaningful: if the two lines end up behaving alike, that similarity is evidence rather than something the plotting code forced.

Reading a Healthy Pair of Curves

In the example this routine is built for, both lines fall sharply during the first epoch. After that, they flatten out gradually and settle toward the fifth epoch. Two readings follow from that shape. The first is that the model is making real learning progress, since the loss drops quickly at the start. The second is that the model learned from the training data and carries that learning over to the unseen validation data, because the validation line follows the training line rather than separating from it.

What do you think happens?

Both curves drop sharply in the first epoch, flatten out, and stay close together. Is the model generalizing?

  • Yes, the validation line follows the training line

  • No, the model has memorized the training data

  • Cannot be judged from loss curves

Reveal answer
Answer:

Yes, the validation line follows the training line

A clear downward trajectory shows learning, and a validation line that tracks the training line shows that what was learned on the training data also fits the held-out data. A healthy plot has both properties at once.

Key point

A healthy plot has two properties at once: a clear downward trajectory, and a validation line that tracks the training line. Missing either one is a reason to look more closely.

The two columns of a comparison have the same shape, and that similarity is the signal. When the training and validation curves move together, the model is generalizing. When one line keeps falling while the other does not follow, the picture no longer supports that conclusion, and you should read the two lines together rather than in isolation.

Adding the Examples-Seen Axis

The routine creates one figure with one axes object, plots both loss lines on it, labels the horizontal axis as epochs and the vertical axis with the loss name, and adds a legend so the two lines can be told apart. Those are the familiar parts of any line plot. The distinctive part comes next: the routine needs a second horizontal scale for examples seen, and that scale is drawn on a separate axes object that shares the same vertical range.

Locating Where a Mismatch Starts

The plotting code can be read as a sequence of stages. Each stage has a specific job, and each produces something the next stage depends on. Following the stages in order makes it possible to see where a problem would enter the picture. The stages redraw only what they are given, so a line that diverges from expectations can come from the lists passed in, the order of arguments, or the epoch positions, before the model itself is blamed.

Training loss listValues from the trainingrunValidation losslistValues from held-out dataEvenly spaced epochpositionsBuilt before plottingTraining lineDrawn from its own listValidation lineDrawn from its own listLabelled figure andlegendOne axes objectExamples-seen twinaxisHidden line sets the scaleLayout, save, showWhatever is on the figurecount of pointscount of pointsx-positionsx-positionsplottedplottedsecond axis addedfinal figure
Where in the data flow could a training or validation curve end up misaligned?

The layout adjustment comes after both axes exist, which is why it can make room for the top label as well as the bottom one. The save and show steps come last, so whatever is on the figure at that point is what gets written to the file and displayed. A mismatch between the expected and actual curves therefore has a short list of places to check: the two input lists, the argument order, and the epoch positions.

Best practice

Start diagnosis at the data feeding the validation line rather than at the model. Confirm that each line is drawn from the list you intended, that the epoch positions match the number of loss values, and that the arguments are passed in the order you expect before concluding that the model behaved badly.

Mistakes Readers Make With Curves

  • Common mistake

    Treating the training line alone as proof of learning

    Why it fails

    A falling training line shows the model fits the data it learned from. It does not show that the fit carries over to unseen data.

    Do this instead

    Read the validation line alongside it and check whether it tracks the training line.

  • Common mistake

    Assuming an invisible top-axis line means something is missing

    Why it fails

    The line is hidden on purpose by setting its transparency to zero, so that the second axis is scaled to the examples-seen values.

    Do this instead

    Check whether the top axis has ticks that match its scale; the hidden line is expected.

  • Common mistake

    Blaming the model for a diverging validation line before checking the data

    Why it fails

    The plotting stages only redraw what they are given, so wrong lists, argument order, or epoch positions can produce a misaligned line.

    Do this instead

    Inspect the input lists, argument order, and epoch positions first.

  • Common mistake

    Reading the top axis as a per-step record

    Why it fails

    The examples-seen sequence is evenly spaced across the run and maps the run as a whole.

    Do this instead

    Use the top axis to read the overall scale of the run, not to find individual steps.

Practice Reading a Run

MEDIUM

Imagine a run where the training loss falls sharply in the first epoch and then flattens, but the validation loss stays flat from the start and does not follow the training line. Using only what this article describes, say whether the model is learning and whether it is generalizing, and name the first two places in the plotting pipeline you would inspect before drawing a conclusion about the model.

Hints
  • Check the two conditions for a healthy plot: a clear downward trajectory and a validation line that tracks the training line.
  • The validation line is drawn from its own list, so start with the list and the argument order that feed it.

Key Takeaways

  • A training loss curve and a validation loss curve are each drawn against epochs from their own list of values; the training curve reflects data the model learns from, and the validation curve reflects held-out data.
  • A healthy run shows a sharp early decline that flattens out, and a validation line that follows the training line, which indicates generalization.
  • The examples-seen axis is a second scale on a twin axes object; its line is made invisible so that the top scale is fitted to the examples-seen values it labels.
  • When a curve looks wrong, check the data pipeline first: the input lists, the argument order, and the evenly spaced epoch positions, before blaming the model.

Related concepts

More concepts starting with I