forked from OpenNMT/OpenNMT-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
executable file
·40 lines (29 loc) · 921 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
37
38
39
40
#!/usr/bin/env python
"""
Main training workflow
"""
from __future__ import division
import argparse
import onmt.opts as opts
from onmt.train_multi import main as multi_main
from onmt.train_single import main as single_main
from onmt.utils.logging import init_logger
def main(opt):
init_logger(opt.log_file)
if opt.rnn_type == "SRU" and not opt.gpuid:
raise AssertionError("Using SRU requires -gpuid set.")
if opt.epochs:
raise AssertionError("-epochs is deprecated please use -train_steps.")
if len(opt.gpuid) > 1:
multi_main(opt)
else:
single_main(opt)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='train.py',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
opts.add_md_help_argument(parser)
opts.model_opts(parser)
opts.train_opts(parser)
opt = parser.parse_args()
main(opt)