Hi, I’d like to load the best weights of my model instead of stopping the whole training when overfitting.
Right now, I’m doing something similar to:
if overfit is True:
     model.load_state_dict(torch.load(path_of_best_weights))

However, when I look at my accuracy I don’t see any difference. It seems like its continuing the training as if nothing happened.
The only thing that worked was to reload the whole model and then load on my best weights:
model = models.resnet18(pretrained=True)
model.load_state_dict(torch.load(path_of_best_weights))

Is there a better way of doing this?