-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide the ability to instantiate the model using the config file generated with LightningCLI #15427
Comments
Instead of using config.yaml (which is only intended for reproducibility) it might be better to extend |
@mauvilsa Wouldn't that hyper-parameter provider load the hyper-parameters from a YAML file anyways? |
It wouldn't be loaded from a yaml file. This would happen on instantiation of the |
You can parse your config using e.g. cfg=Omegaconf.load(..) and then do ModelClass(**cfg.model) |
I created pull request #18105 with an initial implementation for what I proposed in #15427 (comment). Note that this loads from a checkpoint, not from a config. @mouroutzoglou you had in mind instantiating from a config. Does loading from a checkpoint resolve your needs? or is it really necessary to only instantiate without loading any weights? |
Just ran into this issue today. Expected the pl_module to take in hyper_parameters from the checkpoint to initialize, but it instead used my default config values which were different and resulted in a different architecture and failure of loading of state dict. Would love to see this feature added! |
🚀 Feature
Provide to the user some new interface, or modify the existing LightningCLI so that a model can be instantiated for testing/deployment/demos/notebooks/etc using a config.yaml (e.g., the same one generated during training).
Perhaps LightningCLI can have an extra command (besides fit, etc) that only returns the instantiated model, and perhaps the dataloaders.
Motivation
Currently, pytorch lightning lacks this feature (or it's well hidden!). What's the purpose of having modular training setups if you can't instantiate the trained model (for applications mentioned above) using the configs files you trained with. LightningCLI is rather limiting in that sense.
cc @Borda @carmocca @mauvilsa
The text was updated successfully, but these errors were encountered: