Recursive instantiation
See original GitHub issuethis would go well with a change to the config definition of an instantiated object:
Current
model:
cls: foo.bar.ResNet
params:
num_layers: 50
New
model:
_target_: model.ResNet
num_layers: 50
Once this is implemented, we can describe recursive instantiation like:
trainer:
_target_: trainer.Trainer
batch_size: 32
model:
_target_: model.ResNet
num_layers: 50
An remaining open question is how to support passthrough for nested objects.
Currently, passthrough can override individual values:
trainer = instantiate(cfg.trainer, batch_size=64)
a possible approach is for nested objects is to use a dictionary:
trainer = instantiate(cfg.trainer, batch_size=64, overrides={"trainer.model.num_layers": 50})
Issue Analytics
- State:
- Created 3 years ago
- Reactions:19
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Is recursive instantiation possible in Verilog? - Stack Overflow
We need a parameterizable module with N inputs. Inside the module, if N is greater than 2, we instantiate 2 copies of the...
Read more >Recursive instantiation? - Google Groups
I'm trying to create a library of parametrizable components. I'm looking at a priority encoder. I found some code on the web that...
Read more >Recursive instantiation: a synthesis no no?
Hi, What is expected synthesizability of recursively generated instantiation (see below for trivial test case) Is this explicitely prohibited by Verilog ...
Read more >illegal recursive module instantiation of %s" errors
This error occurs if a module attempts to create an instance of itself within the definition (module/endmodule keyword pair of the module). WHAT ......
Read more >Error: "illegal recursive design instantiation" for a well-defined ...
Error: "illegal recursive design instantiation" for a well-defined recursive popcnt module. Elaborates just fine, but throws this error when ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is coming in Hydra 1.1. I have a question for people who liked this issue (indicating that they would like to have this supported):
I would like to make recursive instantiation the default, but this is a breaking change for people that are actually interested in it because right now they are getting the nested config as a config and they need to manually call instantiate on it. Assuming that there will be an alternative way to instantiate non recursively, is such a breaking change acceptable to folks here?
Like this comment to indicate yes and dislike it to indicate no. Feel free to followup with a discussion.
This is now in Hydra master branch. Feedback welcome.