-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
36 lines (28 loc) · 901 Bytes
/
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
from torch.cuda import device_count
from torch.multiprocessing import spawn
from confs.confs import AttrDict
import torch
import json
import argparse
import os
from model_getter import *
from train_impl import train
def main(args):
cfg = AttrDict(
json.load(open(args.conf)))
print(f'ARGS: {args}')
print(f'PARAMS: {cfg}')
ckpts_dir = "checkpoints"
args.model_dir = f"{ckpts_dir}/{cfg.run_name}"
os.makedirs(args.model_dir, exist_ok=True)
train(args, cfg)
def get_parser():
parser = argparse.ArgumentParser(description='train an AudioMPD model')
parser.add_argument('--conf', type=str, required=True)
parser.add_argument('--logger', type=str, choices=['wandb', 'tensorboard', 'none'], default='none')
parser.add_argument('--num_workers', type=int, default=4)
return parser
if __name__ == "__main__":
parser = get_parser()
args = parser.parse_args()
main(args)