It seems you are using a pre-trained model. If that’s the case, you should load the state_dict with the old architecture and change the last layer afterwards. This will make sure that all parameters will be found.