The model parameters should match the stored parameters in the state_dict. Otherwise you’ll get a size mismatch error. You could store the original shapes in the checkpoint, if you think it’s convenient.


You could adapt the code to your use case, but note that the code hasn’t been updated in a while and still uses Variables, which were deprecated in PyTorch 0.4.