Syllabus Lesson 16 of 246 · Module 1: Python for this course
Module 1: Python for this course

Reading a loss curve

Why it matters A training run prints a loss after every pass over the data. Knowing when it stopped getting better tells you when to stop training.

A training log usually has two numbers per epoch (one pass over the data): the loss on the training data, and the loss on held-back validation data the model never trains on. Training loss nearly always keeps falling. Validation loss falls, then often turns back up: the model has started memorising its training data instead of learning the pattern.

Epoch: one full pass over the training data.

The best moment to stop is the epoch where validation loss is lowest. np.argmin finds the position of the smallest value.

Recap Watch validation loss, not training loss. Its lowest point is your best model.

Words and symbols in this lesson
array
a NumPy block of numbers, all the same type, that does maths on every item at once
epoch
one full pass over the training data
Your turn

train_loss and val_loss are given (epochs 1 to 15). Set best_epoch to the epoch number (counting from 1) with the lowest validation loss, and plot both curves on ax with labels "train" and "validation", in that order.

Spotted a problem in this lesson? Report it · Ask about this lesson

This exercise opens soon

Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.