Skip to content

How can I use a weighted loss with LightningCLI? #17953

Discussion options

You must be logged in to vote

You can use an argument link applied on instantiation, see argument-linking. This could be done in several ways, depending on when/where you want setup() to be called. One possibility could be that the LightningModule gets the instance of the LightningDataModule. This is something like:

class MyModule(LightningModule):
    def __init__(self, data_module: LightningDataModule):
        # data setup could be called here or later
        ...

class MyLightningCLI(LightningCLI):
    def add_arguments_to_parser(self, parser):
        parser.link_arguments("data", "model.data_module", apply_on="instantiate")

cli = MyLightningCLI(MyModule, MyDataModule)

Other possibilities are:

  • The LightningDat…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@maxfreu
Comment options

Answer selected by maxfreu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment