Create two copies from the a model?


Suppose I have a model and a certain data. I train the model on the data, now I want to create two independent copies of said trained model. With independent I mean that changes done to one copy of the model should not affect the other copy, or the original model.

I tried to save the trained model with, PATH) and then simply model_copy = torch.load(PATH). But this ends up that these two are “connected”. Is my programming off or why is this the case?

Best regards


How about doing this:

import copy

net_a = torch.load(PATH)
net_b = copy.deepcopy(net_a)