Fix model parameters in PyTorch

Hi, How can I update my model parameters while I am keeping the original one unchanged?

Fix_net = model()
Fix_net = Fix_net.named_parameters()
NotFix_net_par = dict(Fix_net)

net = model()

Now the Fix_net changed as well. However, I would like to update the NotFix_net_par, but keep Fix_net unchangedged

You could use copy.deepcopy fo create NotFix_net_par.

1 Like