Ben Chuanlong Du's Blog

It is never too late to learn.

Save and Load PyTorch Models

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. PyTorch uses pickle to serialize and deserialize objects.

  2. The PyTorch convention is to use the file extension .pt or .pth for saving model (or its parameters) and use the file extension .tar for saving checkpoints.

  3. It is preferred to save model parameters rather than the whole model.

References

SAVING AND LOADING MODELS

SERIALIZATION SEMANTICS

Comments