How to save/load only part of the weights in the model? #9961
Answered
by
rohitgr7
Achazwl
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
-
For example, part of my model's parameters are frozen, no need to train, no need to save |
Beta Was this translation helpful? Give feedback.
Answered by
rohitgr7
Oct 16, 2021
Replies: 1 comment
-
This might work: def on_save_checkpoint(checkpoint):
# pop the backbone here using custom logic
del checkpoint['state_dict'][backbone_keys]
LitModel.load_from_checkpoint(ckpt_path, strict=False) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Achazwl
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This might work: