-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
65 lines (50 loc) · 2.13 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import argparse
import torch
from torch.backends import cudnn
from solver import Solver
from data_loader import get_loader
from hparams import hparams, hparams_debug_string
def str2bool(v):
return v.lower() in ('true')
def main(config):
# For fast training.
cudnn.benchmark = True
# Create directories if not exist.
if not os.path.exists(config.log_dir):
os.makedirs(config.log_dir)
if not os.path.exists(config.model_save_dir):
os.makedirs(config.model_save_dir)
if not os.path.exists(config.sample_dir):
os.makedirs(config.sample_dir)
print("created directories")
# Data loader.
vcc_loader = get_loader(hparams)
print("called data loader")
# Solver for training
solver = Solver(vcc_loader, config, hparams)
print("created solver, startin trainin")
solver.train()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
# Training configuration.
parser.add_argument('--num_iters', type=int, default=1000000, help='number of total iterations')
parser.add_argument('--g_lr', type=float, default=0.0001, help='learning rate for G')
parser.add_argument('--beta1', type=float, default=0.9, help='beta1 for Adam optimizer')
parser.add_argument('--beta2', type=float, default=0.999, help='beta2 for Adam optimizer')
parser.add_argument('--resume_iters', type=int, default=None, help='resume training from this step')
# Miscellaneous.
parser.add_argument('--use_tensorboard', type=str2bool, default=False)
parser.add_argument('--device_id', type=int, default=0)
# Directories.
parser.add_argument('--log_dir', type=str, default='run/logs')
parser.add_argument('--model_save_dir', type=str, default='run/models')
parser.add_argument('--sample_dir', type=str, default='run/samples')
# Step size.
parser.add_argument('--log_step', type=int, default=1000)
parser.add_argument('--sample_step', type=int, default=1000)
parser.add_argument('--model_save_step', type=int, default=1000)
config = parser.parse_args()
print(config)
print(hparams_debug_string())
main(config)