Yeah maybe you are right and the error is somewhere else in the code. Loading the state dict before defining the optimizer would not be possible if I’m not wrong, because calling .load_state_dict() on the optimizer needs that it was defined.