You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During recursive instantiation hydra assumes that encapsulated objects are independent of each other. I need a way to pass fields between them during instantiation.
Motivation
I'm building PyTorch training class that I want to control using hydra with the least amount of code possible. PyTorch requires a specific order of instantiating objects so each more specific component is aware of the previous one. For example: my trainer class has an init function that has signature: def __init__(self, model, dataset, optimizer, scheduler, ...). Optimizer takes model.parameters() as an argument, and scheduler takes optimizer as it's argument in turn. So far the best solution I found is to instantiate model and optimizer outside of hydra, and then pass them to the hydra.utils.instantiate as additional args. Like this:
I'd want recursive instantiation to take into account such dependencies of objects. Preferably I'd want to abstract it away in a config file. For example:
Also PyTorch documentation states that optimizer should be constructed after placing model on the correct device, which would require to call a function between model instantiation and optimizer instantiation. https://pytorch.org/docs/stable/optim.html#constructing-it
The text was updated successfully, but these errors were encountered:
馃殌 Feature Request
During recursive instantiation hydra assumes that encapsulated objects are independent of each other. I need a way to pass fields between them during instantiation.
Motivation
I'm building PyTorch training class that I want to control using hydra with the least amount of code possible. PyTorch requires a specific order of instantiating objects so each more specific component is aware of the previous one. For example: my trainer class has an init function that has signature:
def __init__(self, model, dataset, optimizer, scheduler, ...)
. Optimizer takesmodel.parameters()
as an argument, and scheduler takesoptimizer
as it's argument in turn. So far the best solution I found is to instantiate model and optimizer outside of hydra, and then pass them to thehydra.utils.instantiate
as additional args. Like this:Pitch
I'd want recursive instantiation to take into account such dependencies of objects. Preferably I'd want to abstract it away in a config file. For example:
Additional context
Also PyTorch documentation states that optimizer should be constructed after placing model on the correct device, which would require to call a function between model instantiation and optimizer instantiation. https://pytorch.org/docs/stable/optim.html#constructing-it
The text was updated successfully, but these errors were encountered: