-
Notifications
You must be signed in to change notification settings - Fork 4
/
arguments.py
136 lines (97 loc) · 4.65 KB
/
arguments.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import language
import os
import subprocess
import time
def add_rnn_args(add_arg):
import charmodel
add_arg('-H', '--hidden-size', type=int, default=199,
metavar='<nodes>', help="number of hidden nodes")
add_arg('-e', '--epochs', type=int,
help="how many cycles through the texts to do")
add_arg('-V', '--stop-on-validation-reverse', type=int, default=0,
help="stop after this many worsening validation results")
add_arg('--presynaptic-noise', type=float, default=0.1,
metavar='<float>', help="Add this much presynaptic noise")
add_arg('-l', '--learn-rate', type=float, default=1e-1,
help=charmodel.Net.learn_rate.__doc__)
add_arg('-L', '--leakage', type=float, default=-2.0,
help=("how much training leaks into other classes "
"[0-1] or negative"))
add_arg('--leakage-decay', type=float, default=0.9,
help="change in leakage per epoch")
add_arg('--learn-rate-decay', type=float, default=1,
help="change in learn-rate per epoch")
add_arg('--log-file', help="log to this file")
add_arg('--enable-fp-exceptions', action='store_true',
help="crash on bad floating point errors")
add_arg('--batch-size', type=int, default=30, metavar='<int>',
help="mini-batch size")
add_arg('--temporal-pgm-dump', action='store_true',
help=("save images showing changing state "
"of input/error vectors"))
add_arg('--periodic-pgm-dump', metavar='"({ih,ho,bi}{w,m,d,t})*"',
help=("Periodically dump images of weights;"
"string determines which"))
add_arg('--periodic-pgm-period', type=int, default=10000,
help=("periodicity of periodic-pgm-dump"))
add_arg('--learning-method', type=int, default=4,
help=("0: weighted, 2: simplified N., "
"3: classical, 4: adagrad"))
add_arg('--activation', type=int, default=2,
help=("1: ReLU, 2: ReSQRT, 5: clipped ReLU"))
add_arg('-d', '--bptt-depth', type=int, default=50,
help="how far to backpropagate through time")
add_arg('--ignore-start', type=int, default=10,
help="don't train on this many characters at start")
add_arg('-f', '--filename', help="save net here")
add_arg('--init-method', type=int,
default=charmodel.INIT_FLAT,
help="0: zeros, 1: flat, 2: fan-in, 3: runs")
add_arg('-c', '--control-corpus',
default=language.CONTROL_CORPUS,
help="use this alternative control corpus")
add_arg('--validation-corpus',
default=language.VALIDATION_CORPUS,
help="use this text for validation")
add_arg('-C', '--control-n', default=40, type=int,
help="how many controls to add")
add_arg('--reverse', action='store_true',
help="process all texts in reverse")
add_arg('--save', help='save raw opinions here')
add_arg('--opinion-every', type=int,
help="write an opinion at this interval of epochs")
add_arg('--confab-interval', type=int, metavar='N',
help="confabulate every N generations")
add_arg('--confab-n', type=int,
help="confabulate using this many sub-models")
add_arg('--confab-len', type=int,
help="confabulate line is this long")
add_arg('--confab-caps-marker',
help="this character indicates next char is a capital")
def add_common_args(add_arg, input_dir=True):
add_arg('lang', help="the language to look at")
if input_dir:
add_arg('-i', '--input-dir',
help='find problems here')
add_arg('-o', '--output-dir', help='write results here')
add_arg('-n', '--basename', default='pan',
help="base filenames upon this")
add_arg('-v', '--verbose', action='store_true',
help="print more to stderr")
add_arg('-r', '--rng-seed', type=int, default=-1,
help="rng seed (-1 for auto)")
add_arg('--word-df-threshold', type=float,
help="ignore words in less than this portion of texts")
def make_directory_name(basename, lang, reloading=False):
# make up a good name
here = os.path.dirname(__file__)
git_hash = subprocess.check_output(['git', '-C', here,
'rev-parse',
'--short', 'HEAD']).strip()
now = time.strftime('%Y-%m-%d+%H-%M-%S')
mod = '-'
if subprocess.call(['git', 'diff-files', '--quiet']):
mod = '+'
if reloading:
basename = 'reload-' + basename
return 'results/%s-%s-%s%s-%s' % (basename, lang, git_hash, mod, now)