Skip to content

Is it possible to drop init_args? #113

@florianblume

Description

@florianblume

I've tried to find out in the code whether there are technical reasons for why we need init_args in configs to pass the init arguments for subclasses. I assume there is but I can't see it and was also wondering whether there's a way around it.

My issue is somewhat related to #89.

I'm using Pytorch Lightning and would like to pass the init arguments to my LightningModule subclasses in the same way I pass them to the trainer:

trainer:
    gpus: 2
    deterministic: true
    ...

since this way I can omit init_args in the command line (which makes commands pretty long) and I can pass overwrite parameters in additional configs without having to specify the class_path again (it complains when I only pass init_args). This drove me to putting more and more stuff into the config file I edit before running experiments, instead of having most of it in the default config file.

I assume that you don't need the init_args part when you don't pass subclasses (as in the case of the trainer class) but is there a way to achieve this for subclasses, too, that I'm missing? I guess I could fake it by inserting init_args into the config before class instantiation but that feels a bit wrong. Could it be implemented properly? I'd also be happy to help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions