Boss lesson · Unit 04
A training run, start to finish
Seeds, checkpoints, early stopping and a post-mortem
What you practise
- Seeds, checkpoints and resuming, logging, early stopping, picking the checkpoint to keep, and a post-mortem of a run that went wrong
Try a question from this lesson
Pick one
A ten-hour fine-tune crashes in hour nine with nothing saved. Which habit would have turned that into a few minutes of lost work?
Hint
The crash itself may not be preventable. What decides how much has to be redone?
Correct answer
Saving a checkpoint every so many steps
Why
Crashes happen: a full disk, a lost machine, one bad batch. With periodic checkpoints the cost of any crash is capped at the steps since the last save. Without them, the cost is the whole run.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
What a checkpoint holds
To deploy a model you need its weights. To resume training exactly where it stopped you need more: the optimizer's state (Adam's running averages), the scheduler's position and the step count.
Each has a state_dict(). Collect them in one dict and write it with torch.save.
ckpt = {
'model': model.state_dict(),
'opt': opt.state_dict(),
'sched': sched.state_dict(),
'step': step,
}Concept
Early stopping
Evaluate at regular intervals and remember the best eval loss so far. If it has not improved for a set number of evaluations in a row, called the patience, stop.
Then go back to the checkpoint with the best eval loss. The last checkpoint is the most trained one, not the best one.
10 more exercises in the app
- 3× multiple choice
- 3× type the answer
- 1× fill the blanks
- 1× order the lines
- 1× match the pairs
- 1× true or false
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.