I have used the following codes to update part of the models states and it works
data = torch.load(PATH)
pretrained_states = data[‘model_state_dict’]
model_dict = model.state_dict()
pretrained_states = {k: v for k, v in pretrained_states.items() if k in model_dict}
model_dict.update(pretrained_states)
model.load_state_dict(model_dict)
but when I am trying to load the optmizer state_dict() it gives an error
“loaded state dict contains a parameter group that doesn’t match the size of optimizer’s group”
I am trying to update optimizer state the same way but its not working.