-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
45 lines (38 loc) · 1.01 KB
/
run.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
from pathlib import Path
import shutil
import config
from data import DeEnSetGenerator
from trainer import Trainer
from transformer.blocks import TransformerModel
def main():
loader = DeEnSetGenerator()
model = TransformerModel(
**{
"dec_embed_size": len(loader.vocab_transform["en"]),
"enc_embed_size": len(loader.vocab_transform["de"]),
"padding_idx": loader.pad_idx,
**config.model_hyperparams
}
)
# Create the trainer and start training
model_dir = Path(
config.experiment_parent_path,
config.experiment_name
)
model_dir.mkdir(parents=True, exist_ok=True)
shutil.copy(
Path(config.__file__),
Path(model_dir, "config.py")
)
trainer = Trainer(
model_dir,
model,
loader,
device='cuda'
)
trainer.train(
config.training_hyperparams["epochs"],
config.training_hyperparams["checkpoint_path"],
)
if __name__ == "__main__":
main()