-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aef137b
commit 3ca7e78
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
This file runs the main training/val loop | ||
""" | ||
import os | ||
import json | ||
import sys | ||
import pprint | ||
import torch | ||
|
||
sys.path.append(".") | ||
sys.path.append("..") | ||
|
||
from options.train_options import TrainOptions | ||
from training.coach import Coach | ||
|
||
|
||
def main(): | ||
opts = TrainOptions().parse() | ||
create_initial_experiment_dir(opts) | ||
coach = Coach(opts) | ||
coach.train() | ||
|
||
|
||
def create_initial_experiment_dir(opts): | ||
if os.path.exists(opts.exp_dir): | ||
raise Exception('{} already exists'.format(opts.exp_dir)) | ||
os.makedirs(opts.exp_dir) | ||
|
||
opts_dict = vars(opts) | ||
pprint.pprint(opts_dict) | ||
with open(os.path.join(opts.exp_dir, 'opt.json'), 'w') as f: | ||
json.dump(opts_dict, f, indent=4, sort_keys=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |