-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
52 lines (42 loc) · 1.17 KB
/
train.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
41
42
43
44
45
46
47
48
49
50
51
52
import logging
import hydra
from torch.utils.data import DataLoader
from omegaconf import DictConfig
from midisynth.model.data import SynthMidiDataset
from midisynth.model import Baseline
@hydra.main(version_base=None, config_path="conf", config_name="baseline")
def main(cfg: DictConfig) -> None:
logging.info("Generating Dataloader...")
train_dataloader = DataLoader(
SynthMidiDataset(
cfg.data.train.csv_path,
cfg.feature
),
**cfg.data.train.dataloader
)
val_dataloader = DataLoader(
SynthMidiDataset(
cfg.data.val.csv_path,
cfg.feature
),
**cfg.data.val.dataloader
)
test_dataloader = DataLoader(
SynthMidiDataset(
cfg.data.test.csv_path,
cfg.feature
),
**cfg.data.test.dataloader
)
logging.info("Start Training!")
model = Baseline(cfg.model)
model.fit(
train_dataloader,
val_dataloader,
**cfg.trainer
)
logging.info("Training Finished! Evaluating...")
results = model.evaluate(test_dataloader)
logging.info(results)
if __name__ == "__main__":
main()