"load_from_checkpoint" for Module that uses "from_pretrained" #12513
Unanswered
zorikg
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 1 comment
-
As far as I can see from my experiments, although init reloads the pretrained model, the checkpoint you saved will eventually overwrite it. You can also see this discussion #9236. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say that I fine-tune a model following the example from the guide (attached the code below for convenience). It is not clear to me how do I load this model for inference or additional training.
If I do
BertMNLIFinetuner.load_from_checkpoint(<path_to_saved_checkpoint>)
, then the behavior that I observe is that the Ctor is still called and so is the line withself.bert = BertModel.from_pretrained("bert-base-cased", output_attentions=True)
, which essentially overrides the model weights (right?).What is the recommended practice for loading checkpoint of models that were created with this pattern (i.e. they load a pre-trained model as part of the LightningModule construction)?
Thanks,
Zorik
Beta Was this translation helpful? Give feedback.
All reactions