Andrey Lukyanenko
Senior DS, MTS AI
import hydra
from omegaconf import DictConfig, OmegaConf
@hydra.main(config_name="config")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))
print(f'User name: {cfg.user.name}.'
f'Age: {cfg.user.age}')
if __name__ == "__main__":
my_app()
user:
name: UserName
age: 42
>>> python my_app.py
user:
name: UserName
age: 42
User name: UserName. Age: 42
def configure_optimizers(self):
optimizer = load_obj(self.cfg.optimizer.class_name)(self.model.parameters(),
**self.cfg.optimizer.params)
scheduler = load_obj(self.cfg.scheduler.class_name)(optimizer,
**self.cfg.scheduler.params)
return (
[optimizer],
[{'scheduler': scheduler,
'interval': self.cfg.scheduler.step,
'monitor': self.cfg.scheduler.monitor}],
)
ods.ai @artgor