-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtrain.py
51 lines (27 loc) · 1.08 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
import argparse
import torch
import train_env.asteroid_librimix.asteroid_librimix_trainer as asteroid_librimix_trainer
from utils import get_device
DEVICE = get_device()
def argument_handler():
parser = argparse.ArgumentParser()
#####################################################################
# General Config
#####################################################################
parser.add_argument('--yml_path', '-y', type=str, required=True, help='YML configuration file')
parser.add_argument('--use_cpu', action="store_true", help='Use cpu')
args = parser.parse_args()
return args
def train():
# ------------------------------------
# Read args
# ------------------------------------
args = argument_handler()
device = "cpu" if args.use_cpu or not torch.cuda.is_available() else 'cuda'
# ------------------------------------
# Run training
# ------------------------------------
asteroid_librimix_trainer.train(args.yml_path, device)
print("Training is done!")
if __name__ == '__main__':
train()