-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (36 loc) · 1009 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
41
42
43
#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'Author'
__email__ = 'Email'
# dependency
# built-in
import os
# public
import torch
from lightning.pytorch import seed_everything
# private
from config import Config
from src import trainer
class ACP(object):
"""docstring for ACP"""
def __init__(self):
super(ACP).__init__()
self.config = Config()
self.initialize()
def initialize(self):
# setup device
self.config.device = 'cuda' if torch.cuda.is_available() else 'cpu'
# get trainer
self.trainer = trainer.S2STrainer(self.config)
# setup random seed
seed_everything(self.config.seed, workers=True)
# enable tokenizer multi-processing
if self.config.num_workers > 0:
os.environ['TOKENIZERS_PARALLELISM'] = 'true'
# others
torch.set_float32_matmul_precision('high')
def main() -> None:
acp = ACP()
acp.trainer.train()
if __name__ == '__main__':
main()