Saving all checkpointable objects for the best model

Although this issue has been raised before, I am new to PyTorch and am having some difficulty understanding model checkpointing.

  1. How can we save all checkpointable objects for the best model with the least validation loss? I don’t want to save multiple checkpoints corresponding to different iteration/epoch.

  2. What’s the difference between deep cloning checkpointable objects vs using model.state_dict()?

  1. You could use the code from the ImageNet example to store only the best checkpoint.

  2. If you write them to a file, there won’t be any difference. However, if you want to reload a (temporary) checkpoint after some iterations, you could need to perform a deepcopy, as the state_dict stores references to the parameters.