Pytorch-lightning is not able to load the model checkpoint #12199
-
Hi While training the trained automatically checkpointed the best val_acc and train_loss. I downloaded the checkpoint on colab and tried to load the model to see the outputs. And it seems the model outputs are random. It doesn't looks like I was able to get the model. Link to colab: https://colab.research.google.com/drive/1E9eg3BkBQCsyPjmy1TZ3oR-kK7Ti4JXt#scrollTo=waqBK-6WaxrX Please help if I am doing something wrong here. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
hey @yashrathi-git ! your code looks correct. model = LitModel.load_from_checkpoint(...)
trainer = Trainer(...)
trainer.validate(model) # or trainer.test(model) if the above gives you the desired metrics then the model is loaded correctly. one more thing, you might need to call |
Beta Was this translation helpful? Give feedback.
hey @yashrathi-git !
your code looks correct.
Why do you think that outputs are random?
you can also validate your model after loading using:
if the above gives you the desired metrics then the model is loaded correctly.
one more thing, you might need to call
model.eval()
after loading the weights from the checkpoint.