I think you are only accessing a copy of the parameters data here:



 Cedric_Gullentops:

for key in keys: self.network.state_dict()[key] = new_state_dict[key]


Why not just this ?
    def load(self, filename):
        new_state_dict = torch.load(filename, 'cpu')
        self.network.load_state_dict(new_state_dict)

EDIT:
The above won’t work if the dimensions don’t match. So, in your case, I would recreate all network from scratch but having the right dimensions, and simply do a self.network.load_state_dict(...), like below:
import torch

net = torch.nn.Linear(2, 2)
new_state_dict = {'weight': torch.rand(1, 2), 'bias': torch.rand(1)}

net.load_state_dict(new_state_dict) # <- this won't work

new_net = torch.nn.Linear(2, 1)
new_net.load_state_dict(new_state_dict) # <- this works