-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
40 lines (29 loc) · 901 Bytes
/
main.py
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
35
36
37
38
39
40
import os
import random
import numpy as np
import hydra
import torch
from setml.config import Config
from setml.datasets import build_datasets
from setml.trainers import build_trainer
from setml.experiments import Experiment
def set_random_seeds(seed: int) -> None:
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
@hydra.main(version_base=None, config_path="config", config_name="config")
def main(config: Config) -> None:
set_random_seeds(config.experiment.random_seed)
train_set, valid_set, test_set = build_datasets(config)
trainer = build_trainer(config=config, train_set=train_set)
experiment = Experiment(
config=config,
train_set=train_set,
valid_set=valid_set,
test_set=test_set,
trainer=trainer,
)
experiment.run()
if __name__ == "__main__":
main()