-
Notifications
You must be signed in to change notification settings - Fork 59
/
va.sh
executable file
·256 lines (244 loc) · 7.25 KB
/
va.sh
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
TEXT=data/iwslt14-de-en
DATA=data/iwslt/iwslt_125
DATATEST=data/iwslt/iwslt_125_test
preprocess_bpe(){
# Preprocesses the data in data/iwslt14-de-en
# Since we are using BPE, we do not force any unks.
mkdir -p data/iwslt
python preprocess.py \
-train_src ${TEXT}/train.de.bpe -train_tgt ${TEXT}/train.en.bpe \
-valid_src ${TEXT}/valid.de.bpe -valid_tgt ${TEXT}/valid.en.bpe \
-src_vocab_size 80000 -tgt_vocab_size 80000 \
-src_words_min_frequency 0 -tgt_words_min_frequency 0 \
-src_seq_length 125 -tgt_seq_length 125 \
-save_data $DATA
# Get the test data for evaluation
python preprocess.py \
-train_src ${TEXT}/train.de.bpe -train_tgt ${TEXT}/train.en.bpe \
-valid_src ${TEXT}/test.de.bpe -valid_tgt ${TEXT}/test.en.bpe \
-src_vocab_size 80000 -tgt_vocab_size 80000 \
-src_words_min_frequency 0 -tgt_words_min_frequency 0 \
-src_seq_length 125 -tgt_seq_length 125 \
-leave_valid \
-save_data $DATATEST
}
train_cat_sample_b6() {
gpuid=0
seed=3435
name=model_cat_sample_b6
python train.py \
-data $DATA \
-save_model $name -gpuid $gpuid -seed $seed \
-mode sample \
-batch_size 6 \
-encoder_type brnn \
-inference_network_type bigbrnn \
-inference_network_rnn_size 512 \
-src_word_vec_size 512 \
-tgt_word_vec_size 512 \
-memory_size 1024 \
-decoder_rnn_size 768 \
-attention_size 512 \
-accum_count 1 \
-valid_batch_size 2 \
-epochs 30 \
-p_dist_type categorical \
-q_dist_type categorical \
-alpha_transformation sm \
-global_attention mlp \
-optim adam -learning_rate 3e-4 \
-adam_eps 1e-8 \
-n_samples 1 \
-start_decay_at 2 \
-learning_rate_decay 0.5 \
-report_every 1000 | tee $name.log
}
train_cat_gumbel_b6() {
gpuid=0
seed=3435
name=model_cat_gumbel_b6
python train.py \
-data $DATA \
-save_model $name -gpuid $gpuid -seed $seed \
-mode gumbel \
-batch_size 6 \
-temperature 0.1 \
-encoder_type brnn \
-inference_network_type bigbrnn \
-inference_network_rnn_size 512 \
-src_word_vec_size 512 \
-tgt_word_vec_size 512 \
-memory_size 1024 \
-decoder_rnn_size 768 \
-attention_size 512 \
-accum_count 1 \
-valid_batch_size 2 \
-epochs 30 \
-p_dist_type categorical \
-q_dist_type categorical \
-alpha_transformation sm \
-global_attention mlp \
-optim adam -learning_rate 3e-4 \
-adam_eps 1e-8 \
-n_samples 1 \
-start_decay_at 2 \
-learning_rate_decay 0.5 \
-report_every 1000 | tee $name.log
}
train_cat_wsram_b6() {
gpuid=0
seed=3435
name=model_cat_wsram_b6
python train.py \
-data $DATA \
-save_model $name -gpuid $gpuid -seed $seed \
-mode wsram \
-batch_size 6 \
-encoder_type brnn \
-inference_network_type bigbrnn \
-inference_network_rnn_size 512 \
-src_word_vec_size 512 \
-tgt_word_vec_size 512 \
-memory_size 1024 \
-decoder_rnn_size 768 \
-attention_size 512 \
-accum_count 1 \
-valid_batch_size 6 \
-epochs 30 \
-p_dist_type categorical \
-q_dist_type categorical \
-alpha_transformation sm \
-global_attention mlp \
-optim adam -learning_rate 3e-4 \
-adam_eps 1e-8 \
-n_samples 5 \
-start_decay_at 2 \
-learning_rate_decay 0.5 \
-report_every 1000 | tee $name.log
}
train_cat_enum_b6() {
gpuid=0
seed=3435
name=model_cat_enum_b6
python train.py \
-data $DATA \
-save_model $name -gpuid $gpuid -seed $seed \
-mode enum \
-batch_size 6 \
-encoder_type brnn \
-inference_network_type bigbrnn \
-inference_network_rnn_size 512 \
-src_word_vec_size 512 \
-tgt_word_vec_size 512 \
-memory_size 1024 \
-decoder_rnn_size 768 \
-attention_size 512 \
-accum_count 1 \
-valid_batch_size 2 \
-epochs 30 \
-p_dist_type categorical \
-q_dist_type categorical \
-alpha_transformation sm \
-global_attention mlp \
-optim adam -learning_rate 3e-4 \
-adam_eps 1e-8 \
-n_samples 1 \
-start_decay_at 2 \
-learning_rate_decay 0.5 \
-report_every 1000 | tee $name.log
}
train_exact_b6() {
gpuid=0
seed=3435
name=model_exact_b6
python train.py \
-data $DATA \
-save_model $name -gpuid $gpuid -seed $seed \
-mode exact \
-use_generative_model 1 \
-batch_size 6 \
-encoder_type brnn \
-inference_network_type bigbrnn \
-inference_network_rnn_size 512 \
-src_word_vec_size 512 \
-tgt_word_vec_size 512 \
-memory_size 1024 \
-decoder_rnn_size 768 \
-attention_size 512 \
-accum_count 1 \
-valid_batch_size 2 \
-epochs 30 \
-p_dist_type categorical \
-q_dist_type categorical \
-alpha_transformation sm \
-global_attention mlp \
-optim adam -learning_rate 3e-4 \
-adam_eps 1e-8 \
-n_samples 1 \
-start_decay_at 2 \
-learning_rate_decay 0.5 \
-report_every 1000 | tee $name.log
}
train_soft_b6() {
# The parameters for the soft model are slightly different
seed=3435
name=model_soft_b6
gpuid=0
python train.py \
-data $DATA \
-save_model $name -gpuid $gpuid -seed $seed \
-src_word_vec_size 512 \
-tgt_word_vec_size 512 \
-memory_size 1024 \
-decoder_rnn_size 768 \
-attention_size 512 \
-encoder_type brnn -batch_size 6 \
-accum_count 1 -valid_batch_size 32 \
-epochs 30 -optim adam \
-learning_rate 3e-4 \
-adam_eps 1e-8 \
-start_decay_at 2 \
-global_attention mlp \
-report_every 1000 | tee $name.log
}
eval_cat() {
model=$1
python train.py \
-data $DATATEST \
-eval_with $model \
-save_model none -gpuid 0 -seed 131 -encoder_type brnn -batch_size 4 \
-accum_count 1 -valid_batch_size 1 -epochs 30 -inference_network_type bigbrnn \
-p_dist_type categorical -q_dist_type categorical -alpha_transformation sm \
-global_attention mlp \
-optim adam -learning_rate 3e-4 -n_samples 1 -mode sample \
-eval_only 1
}
gen_cat() {
model=$1
python translate.py \
-src data/iwslt14-de-en/test.de.bpe \
-beam_size 10 \
-batch_size 2 \
-length_penalty wu \
-alpha 1 \
-eos_norm 3 \
-gpu 0 \
-output $model.out \
-model $model
}
gen_cat_k() {
model=$1
for k in 1 2 3 4 5; do
python translate.py \
-src data/iwslt14-de-en/test.de.bpe \
-beam_size 10 \
-k $k \
-batch_size 2 \
-length_penalty wu \
-alpha 1 \
-eos_norm 3 \
-gpu 0 \
-output $model.$k.out \
-model $model
done
}