-
-
Notifications
You must be signed in to change notification settings - Fork 758
Closed
Labels
Milestone
Description
The below text is copied directly from a post by a user of the internal Meta Hydra users group:
It seems that Hydra doesn't support recursive instantiation for list objects yet. For example, I would expect the following code to work, but it's raising an InstantiationException: Top level config has to be OmegaConf DictConfig, plain dict, or a Structured Config class or instance.
hydra.utils.instantiate([
{"_target_": "torch.nn.Linear", "in_features": 3, "out_features": 4},
{"_target_": "torch.nn.Linear", "in_features": 4, "out_features": 5},
])
# hydra.errors.InstantiationException: Top level config has to be OmegaConf DictConfig, plain dict, or a Structured Config class or instanceAs another example, we often instantiate a list of callbacks and pass them to a trainer. Although the same thing can be done with a list comprehension, you can probably imagine its usefulness when composed with other structures. This looks like a simple and intuitive feature, so I'm curious if we plan to support it, if it hasn't been done already.
jieru-hu, mayeroa and swertz