-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathstate.py
executable file
·167 lines (126 loc) · 4.72 KB
/
state.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
from collections import OrderedDict
def prototype_state():
state = {}
# Random seed
state['seed'] = 1234
# Logging level
state['level'] = 'DEBUG'
state['oov'] = '<unk>'
state['len_sample'] = 40
# These are end-of-sequence marks
state['start_sym_sentence'] = '<s>'
state['end_sym_sentence'] = '</s>'
state['end_sym_triple'] = '</t>'
state['unk_sym'] = 0
state['eot_sym'] = 3
state['eos_sym'] = 2
state['sos_sym'] = 1
state['maxout_out'] = False
state['deep_out'] = True
# ----- ACTIV ----
state['sent_rec_activation'] = 'lambda x: T.tanh(x)'
state['triple_rec_activation'] = 'lambda x: T.tanh(x)'
state['decoder_bias_type'] = 'all' # first, or selective
state['sent_step_type'] = 'gated'
state['triple_step_type'] = 'gated'
# ----- SIZES ----
# Dimensionality of hidden layers
state['qdim'] = 512
# Dimensionality of triple hidden layer
state['sdim'] = 1000
# Dimensionality of low-rank approximation
state['rankdim'] = 256
# Threshold to clip the gradient
state['cutoff'] = 1.
state['lr'] = 0.0001
# Early stopping configuration
state['patience'] = 5
state['cost_threshold'] = 1.003
# ----- TRAINING METHOD -----
# Choose optimization algorithm
state['updater'] = 'adam'
# Maximum sequence length / trim batches
state['seqlen'] = 80
# Batch size
state['bs'] = 80
# Sort by length groups of
state['sort_k_batches'] = 20
# Maximum number of iterations
state['max_iters'] = 10
# Modify this in the prototype
state['save_dir'] = './'
# ----- TRAINING PROCESS -----
# Frequency of training error reports (in number of batches)
state['train_freq'] = 10
# Validation frequency
state['valid_freq'] = 5000
# Number of batches to process
state['loop_iters'] = 3000000
# Maximum number of minutes to run
state['time_stop'] = 24*60*31
# Error level to stop at
state['minerr'] = -1
# ----- EVALUATION PROCESS -----
state['track_extrema_validation_samples'] = True # If set to true will print the extrema (lowest and highest log-likelihood scoring) validation samples
state['track_extrema_samples_count'] = 100 # Set of extrema samples to track
state['print_extrema_samples_count'] = 5 # Number of extrema samples to print (chosen at random from the extrema sets)
state['compute_mutual_information'] = True # If true, the empirical mutural information will be calculcated on the validation set
return state
def prototype_test():
state = prototype_state()
# Fill your paths here!
state['train_triples'] = "./tests/data/ttrain.triples.pkl"
state['test_triples'] = "./tests/data/ttest.triples.pkl"
state['valid_triples'] = "./tests/data/tvalid.triples.pkl"
state['dictionary'] = "./tests/data/ttrain.dict.pkl"
state['save_dir'] = "./tests/models/"
# Handle bleu evaluation
state['bleu_evaluation'] = "./tests/bleu/bleu_evaluation"
state['bleu_context_length'] = 2
# Validation frequency
state['valid_freq'] = 50
# Varia
state['prefix'] = "testmodel_"
state['updater'] = 'adam'
state['maxout_out'] = False
state['deep_out'] = True
# If out of memory, modify this!
state['bs'] = 80
state['use_nce'] = True
state['decoder_bias_type'] = 'all' #'selective'
state['qdim'] = 50
# Dimensionality of triple hidden layer
state['sdim'] = 100
# Dimensionality of low-rank approximation
state['rankdim'] = 25
return state
def prototype_moviedic():
state = prototype_state()
# Fill your paths here!
state['train_triples'] = "Data/Training.triples.pkl"
state['test_triples'] = "Data/Test.triples.pkl"
state['valid_triples'] = "Data/Validation.triples.pkl"
state['dictionary'] = "Data/Training.dict.pkl"
state['save_dir'] = "Output"
# Handle bleu evaluation
state['bleu_evaluation'] = "Data/Validation_Shuffled_Dataset.txt"
state['bleu_context_length'] = 2
# Validation frequency
state['valid_freq'] = 5000
# Varia
state['prefix'] = "MovieScriptModel_"
state['updater'] = 'adam'
state['maxout_out'] = True
state['deep_out'] = True
# If out of memory, modify this!
state['bs'] = 80
state['use_nce'] = False
state['decoder_bias_type'] = 'all' # Choose between 'first', 'all' and 'selective'
# Increase sequence length to fit movie dialogues better
state['seqlen'] = 160
state['qdim'] = 600
# Dimensionality of triple hidden layer
state['sdim'] = 300
# Dimensionality of low-rank approximation
state['rankdim'] = 300
return state