-
Notifications
You must be signed in to change notification settings - Fork 13
/
os_run_model.py
executable file
·65 lines (51 loc) · 1.93 KB
/
os_run_model.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
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os.path
import time
import math
import sys
from six.moves import xrange # pylint: disable=redefined-builtin
import tensorflow as tf
from optparse import OptionParser
from models.static_model import *
from models.basic_files.dataset_iterator import *
from run_model import *
import os
def main():
parser = OptionParser()
parser.add_option(
"-w", "--work-dir", dest="wd", default="../Data/")
parser.add_option(
"-l", "--learning-rate", dest="lr", default=0.0001)
parser.add_option(
"-e", "--embedding-size", dest="emb_size",
help="Size of word embeddings", default=50)
parser.add_option(
"-s", "--hidden-size", dest="hid_size",
help="Hidden size of the cell unit", default=100)
parser.add_option(
"-a", "--batch-size", dest="batch_size",
help="Number of examples in a batch", default=32)
parser.add_option(
"-n", "--epochs", dest="epochs",
help="Maximum Number of Epochs", default=10)
parser.add_option(
"-t", "--early_stop", dest="early_stop",
help="Stop after these many epochs if performance on validation is not improving", default=2)
parser.add_option(
"-o", "--output_dir", dest="outdir",
help="Output directory where the model will be stored", default="../out/")
parser.add_option(
"-x", "--emb-train", dest="emb_tr")
(option, args) = parser.parse_args(sys.argv)
if (int(option.emb_tr) == 1):
x = True
else:
x = False
c = Config(float(option.lr), int(option.emb_size), int(option.hid_size), int(option.batch_size),
int(option.epochs), early_stop=int(option.early_stop), outdir= option.outdir, emb_tr=x)
run_attention = run_model(option.wd, BasicAttention(), c)
run_attention.run_training()
if __name__ == '__main__':
main()