Saving and Loading Preview
Training is an experiment. Experiments need state.
In PyTorch, the most common saved object is a state dictionary. It stores named tensors such as weights and biases.
torch.save(model.state_dict(), "model.pt")
Later, a model with the same structure can load those values:
model.load_state_dict(torch.load("model.pt"))
model.eval()
This preview matters because saved state separates the model definition from the learned values. The code says what computation exists. The state dictionary stores the particular parameters learned during training.
For a fuller experiment, the saved checkpoint may include:
- model state
- optimizer state
- current epoch or step
- configuration values
- random seed or other reproducibility notes
That extra state helps resume training or explain how a result was produced.
For now, the main idea is simple: saving a model usually means saving the trained tensors, not freezing the whole learning process into a mysterious object.
Answer it first, then check.
Saving and loading make experiments durable, inspectable, and repeatable.