I am trying to copy a modified state_dict from a model that was pruned (e.g. reducing the 0 dimension of one of the tensors by 1). The models have the same keys, the only difference is the dimensions of the tensors. I made a wrapper class to handle pruned networks as seen below:
class PrunedNetwork():
    def __init__(self, network):
        self.network = network

    def __getattr__(self, name):
        return getattr(self.network, name)

    def forward(self, *args, **kwargs):
        self.network.forward(*args, **kwargs)

    def save(self, filename):
        self.network.save(filename)

    def load(self, filename):
        new_state_dict = torch.load(filename, 'cpu')

        for param_tensor in self.network.state_dict():
            print(param_tensor, "\t", self.network.state_dict()[param_tensor].size())

        # TODO: copy new_state_dict into state_dict
        # The following attempt doesn't work
        keys = self.network.state_dict().keys()
        for key in keys:
            self.network.state_dict()[key] = new_state_dict[key]
        
        self.network.load(filename)

The tensors aren’t being copied over to the model.