Torch.load(model) is giving inconsistent results for different iterations during re-training

I ran a training job for some n sample with a given architecture and save the model using torch.save().

Now, I want to use the saved model (it’s weights) to run a different training job with

  • exact same architecture
  • a large number (m samples) of similar (but not same) data
  • more epocs

However, when I use model = torch.load(saved_model) as my model for re-training the new job, I get inconsistent results i.e. I get different predictions for different run (clear variables, restart kernel) of the new training job.

Sample code can be seen here: How to use pretrained weights for initializing the weights in next iteration?

Hi,

Just load weights as a dicitionary where the keys are positions of the layers. You need to assign this weights to the defined model using model.load_state_dict(weights) where weights = torch.load("my_model.pt"). Have you tried that as the post you have mentioned?

Bests