Hi,
Before my answer, could you tell me where checkpoint came from in the below snippet?



 jul:

state = {‘model’:model,‘epoch’: epoch,‘state_dict’:model.state_dict(), ‘optimizer’: optimizer.state_dict()}
torch.save(state, os.path.join(path_,‘model_’+name_+’.tar’))
#and to load it again:
state = torch.load(os.path.join(path,‘model_’+name_+’.tar’))
model2 = checkpoint(‘model’)
model2.load_state_dict(state[‘state_dict’])
pprint(model2)



All the answer below is derived from my little understanding.
As to your question 2 and 3.
When you save models by torch.save, pytorch saves states_dict and the source code of the model ref using inspect.
This means

the serialized data is bound to the specific classes and the exact directory structure used, so it can break in various ways when used in other projects, or after some serious refactors.

as written in https://pytorch.org/docs/master/notes/serialization.html 4.
So, in the long run, it’s preferable to save model and its state_dict separately though you don’t like the process.