Dynamically Setting out_dim Based on LightningDataModule in LightningCLI #20602
Unanswered
aditya0by0
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 1 comment
-
You have two options:
|
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
-
Dynamically Setting
out_dim
Based onLightningDataModule
in LightningCLIHi all,
I’m looking for a way to dynamically set the
out_dim
parameter in myLightningModule
. Currently, this is passed explicitly via the command line, but I want to avoid that and instead have it automatically set based on thenum_of_labels
from theLightningDataModule
. The problem is thatnum_of_labels
is determined inside thesetup
method of theDataModule
, not during its initialization.I tried using
link_arguments
to link thenum_of_labels
from theDataModule
to theout_dim
in theLightningModule
, but it doesn’t seem to work for this use case.I’ve created a minimal example of the code below to illustrate the issue:
Note :
num_of_labels
can only be determined insetup
method of the datamodule in below case, and not in constructor.As you can see, I’m trying to use
link_arguments
to linknum_of_labels
toout_dim
, but sincenum_of_labels
is determined in thesetup
method (not the constructor), I’m running into issues.Has anyone encountered a similar situation or found a way to dynamically set the
out_dim
based on the data module? Is there a better way to achieve this, or am I missing something?Any feedback or suggestions would be greatly appreciated!
Thanks in advance!
Environment
Beta Was this translation helpful? Give feedback.
All reactions