-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
[Need help] How to init an object of a class with position parameters in yaml config file? Also how to call a func to init an object in yaml file? #407
Comments
Variable positional arguments import torch.nn
class Sequential(torch.nn.Sequential):
def __init__(self, modules: list[Module]):
super().__init__(*modules) Then in a config file: class_path: your.module.Sequential
init_args:
modules:
- class_path: module1
- ...
This has been requested in many issues. Right now I don't remember where else it has been requested to reference here. But it is not yet supported, and it is not a simple feature to implement. For the time being, this is only possible by using classes-from-functions. |
@mauvilsa Ok, got it. Thanks for your reply very much. But, is there any plan to support those two features, the features about init objects with position parameters and objects from function? Thanks for you gays' great efforts for this useful lib again. |
All features are potential future additions, unless stated otherwise. But note that the list of possible features is large, and I don't mean only the ones publicly seen in issues. There is also a private list of things that can be added/improved. What gets implemented and when depends on many factors. |
Thanks for your explaination and all you guys' great work. I can not wait until the day when I get the news that those features are gotten supported. :) |
An update. Providing to Support for functions without return type annotation will not be added. Doing so would open the door to executing arbitrary functions from a config file. If you want to us a function in some public package that doesn't have a return annotation, consider opening a pull request in that project. Regarding |
Actually an update for |
🚀 Feature request
We can init an object with keyword parameters already, which is very helpful. An example:
But, what should I do if I want to use a torch.nn.Sequential or other class requiring position parameters instead of ModuleDict? The init func of nn.Sequential:
And, how to use a func to init an object? For example, I have a func like this:
What should I do if I want something like:
The text was updated successfully, but these errors were encountered: