Deep copying PyTorch modules

If I had to deep copy a model, I would do something like this…

model_copy = type(mymodel)() # get a new instance
model_copy.load_state_dict(mymodel.state_dict()) # copy weights and stuff

I can’t see how that would help you “save it somewhere else in a database”. I assume you have read the docs on serialising models and the recommendations and warnings on that page.

13 Likes