KeyError: 'self' in save_hyperparameters() when custom metaclass used #20693
Unanswered
aditya0by0
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 3 comments
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Question Answered in stackoverflow: https://stackoverflow.com/questions/79554986/keyerror-self-in-save-hyperparameters-when-custom-metaclass-used-pytorch |
Beta Was this translation helpful? Give feedback.
0 replies
-
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.
-
Description
I'm working with
LightningDataModule
and wanted to ensure that a method (_after_init
) runs only once after full initialization, regardless of subclassing. For that, I implemented a custom metaclass (_InitMeta
) that overrides__call__
to invoke_after_init
after the instance is fully created.When using create an instance of final subclass, I encounter a KeyError: 'self' inside save_hyperparameters().
I’ve created a minimal example of the code below to illustrate the issue:
Code Snippet
Error Output
Any feedback or suggestions would be greatly appreciated!
Thanks in advance!
Environment
Beta Was this translation helpful? Give feedback.
All reactions