Hello,
I am currently trying to map the parameters of a pre-trained network to another network of the exact same architecture, but with a different arrangement of sub-modules. Here is how I am doing it:
def _load_parameters(self):
        
        self.old_state_dict = torch.load(f = self.param_path,
                                         map_location = torch.device('cpu'))
        
        # make a copy to use load_state_dict() method later
        
        state_dict = copy.deepcopy(self.state_dict())
        
        with open('state_dict_map.csv',newline='') as csvfile:
            reader = csv.reader(csvfile,delimiter=',')
            for old_key,new_key in reader:
                state_dict[new_key] = self.old_state_dict[old_key]
        
        self.load_state_dict(state_dict)

This function is defined in the Net() class that also contains the forward() method. The state_dict_map.csv file contains mappings from old parameter names to new parameter names. For example:
module.layer1.0.weight,stage1.0.weight
module.layer1.0.bias,stage1.0.bias
module.layer1.1.weight,stage1.1.weight

While debugging, just before I run self.load_state_dict(state_dict), I check the following parameters:
>>> self.old_state_dict[module.layer1.1.weight]
tensor([1.1605, 1.0575, 0.8263, 1.1720, 0.8299, 0.9742, 0.7409,
1.0015, 0.9154, 0.7924, 0.7753, 1.1176, 0.8313, 0.9920, 1.0639, 1.0233])

>>> state_dict['stage1.1.weight']
tensor([1.1605, 1.0575, 0.8263, 1.1720, 0.8299, 0.9742, 0.7409,
1.0015, 0.9154, 0.7924, 0.7753, 1.1176, 0.8313, 0.9920, 1.0639, 1.0233])

Clearly, they are the same, which is expected. Also, the original state_dict has not yet been modified:
>>> self.state_dict()['stage1.1.weight']
tensor([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])

However, after I run self.load_state_dict(state_dict), I get this:
>>> self.state_dict()['stage1.1.weight']
tensor([1.0268, 1.0117, 1.0257, 1.0075, 0.9960, 0.9114, 0.9855,
0.9940, 0.9469, 0.9148, 0.9430, 1.0411, 0.9435, 1.1579, 0.9916, 1.0996])

Which is not the same as:
>>> state_dict['stage1.1.weight']
tensor([1.1605, 1.0575, 0.8263, 1.1720, 0.8299, 0.9742, 0.7409,
1.0015, 0.9154, 0.7924, 0.7753, 1.1176, 0.8313, 0.9920, 1.0639, 1.0233])

FYI, module.layer1.1.weight and stage1.1.weight are batch normalization layers, but I get the same problem for all layers in the net, including convolutional layers. I am not sure where exactly these numbers came from. Any suggestions?
Thanks.