-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.py
More file actions
34 lines (25 loc) · 1.11 KB
/
train.py
File metadata and controls
34 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Main training script"""
import os
import dotenv
import hydra
from omegaconf import DictConfig, OmegaConf
from hyperparameter_searcher.training_pipeline import train
# load environment variables from `.env` file if it exists
# recursively searches for `.env` in all folders starting from work dir
# see .env.example file
dotenv.load_dotenv(override=True)
@hydra.main(config_path=None, config_name=os.environ["MAIN_CONFIG"])
def main(config: DictConfig):
"""Here we call the training pipeline and perhaps do some extra stuff"""
print(OmegaConf.to_yaml(config))
# Train model
return train(config)
if __name__ == "__main__":
# import the configs only here, since we want dotenv to run before the configs -- to register environment variables
from hyperparameter_searcher.config.train_grid_config import register_grid_configs
from hyperparameter_searcher.config.train_bayesian_config import (
register_bayesian_configs,
)
register_grid_configs() # register hydra configs
register_bayesian_configs() # register hydra config
main() # pylint: disable = no-value-for-parameter