Load weight from checkpoint with class that takes mandatory arguments #8619
Unanswered
Loris697
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 0 comments
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi to all,
I'm quite new to GitHub, maybe this question is in the wrong place. If something is missing I will update it later.
I'm using a PL model: a class that takes two mandatory arguments and other optional:
class PLModel(pl.LightningModule): def __init__(self, name, model, ...)
I saved the weight using a callback during the training:
checkpoint_callback = ModelCheckpoint( monitor='balValAcc', dirpath=folder, filename= '{epoch:02d}-{balValAcc:.2f}', save_top_k=3, mode='max', )
But when I try to load the checkpoints in this way:
try: testModel = PLModel(model.name, model.model).load_from_checkpoint(checkpoint_path=mypath + '/' + weightName) except Exception as e: print(e)
I get:
init() missing 2 required positional arguments: 'name' and 'model'
The I tried to change the code to
try: testModel = PLModel(model.name, model.model).load_from_checkpoint(mypath + '/' + weightName, model.name, model.model) except Exception as e: print(e)
but i get another error message:
don't know how to restore data location of torch.FloatStorage (tagged with EfficientNetB7)
Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions