-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (36 loc) · 1021 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__ = 'Shining'
__email__ = 'mrshininnnnn@gmail.com'
# dependency
# built-in
import os
# public
import torch
from lightning import seed_everything
# private
from config import Config
from src import trainers
class LSP(object):
"""docstring for LSP"""
def __init__(self):
super(LSP).__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 = trainers.LSPTrainer(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:
lsp = LSP()
lsp.trainer.train()
if __name__ == '__main__':
main()