-
Notifications
You must be signed in to change notification settings - Fork 1
/
hyperparams.py
213 lines (165 loc) · 7.05 KB
/
hyperparams.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
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
# -*- coding: utf-8 -*-
#/usr/bin/python2
'''
June 2017 by kyubyong park.
https://www.github.com/kyubyong/transformer
'''
from nsml import DATASET_PATH
import os
class CNNDM_Hyperparams: # for CNNDM data
logdir = 'logdir' # log directory
tb_dir = 'tbdir'
checkpoint_steps = 1000
eval_record_threshold = 1000
eval_record_steps = 200 # should be larger than checkpoint_steps? otherwise would duplicate
train_record_steps = 50
num_ml_epoch = 60
num_epochs = num_ml_epoch
batch_size = 50 # orig:32
## data source
source_train = os.path.join(DATASET_PATH, 'train', 'train_content.txt')
target_train = os.path.join(DATASET_PATH, 'train', 'train_summary.txt')
source_valid = os.path.join(DATASET_PATH, 'train', 'val_content.txt') # change
target_valid = os.path.join(DATASET_PATH, 'train', 'val_summary.txt') # change
source_test = os.path.join(DATASET_PATH, 'train', 'test_content.txt')
sum_dict = os.path.join(DATASET_PATH, 'train', 'dict.txt')
doc_dict = sum_dict
## data parameter
min_cnt = 20 # words whose occurred less than min_cnt are encoded as <UNK>.
article_minlen = 100
article_maxlen = 400 # Maximum number of words in a sentence. alias = T.
summary_minlen = 20
summary_maxlen = 100 # Maximum number of words in a sentence. alias = T.
## training parameter
sinusoid = False # If True, use sinusoid. If false, positional embedding.
hidden_units = 512 # alias = C # orig: 512
ffw_unit = 2048 # orig: 2048
num_blocks = 3
num_heads = 8
lr = 0.00003
dropout_rate = 0.1
eta_init = 0.95
maxgradient = 1000
class giga_Hyperparams: # giga
## log path; frequency
logdir = 'logdir' # log directory
tb_dir = 'tbdir'
checkpoint_steps = 1000
eval_record_threshold = 5000
eval_record_steps = 1000 # should be larger than checkpoint_steps? otherwise would duplicate
train_record_steps = 200
eta_thredshold = 15
batch_size = 80 # orig:32
num_epochs = 15
## data source
source_train = os.path.join(DATASET_PATH, 'train', 'train', 'train.article.txt')
target_train = os.path.join(DATASET_PATH, 'train', 'train', 'train.title.txt')
source_valid = os.path.join(DATASET_PATH, 'train', 'train', 'valid.article.filter.txt')
target_valid = os.path.join(DATASET_PATH, 'train', 'train', 'valid.title.filter.txt')
source_test = os.path.join(DATASET_PATH, 'train', 'test', 'test.giga.txt')
sum_dict = os.path.join(DATASET_PATH, 'train', 'train', 'full_dict.txt')
doc_dict = sum_dict
## data parameter
min_cnt = 20 # words whose occurred less than min_cnt are encoded as <UNK>.
article_minlen = 20
article_maxlen = 40 # Maximum number of words in a sentence. alias = T.
summary_minlen = 5
summary_maxlen = 11 # Maximum number of words in a sentence. alias = T.
## training parameter
sinusoid = False # If True, use sinusoid. If false, positional embedding.
hidden_units = 512 # alias = C # orig: 512
ffw_unit = 2048 # orig: 2048
num_blocks = 3 # number of encoder/decoder blocks
num_heads = 8
lr = 0.0001
dropout_rate = 0.1
eta_init = 0.0
maxgradient = 1000
class Hyperparams: # for LCSTS char data
## log path; frequency
pretrain_logdir = './' # log directory
logdir = 'logdir'
tb_dir = 'tbdir'
checkpoint_steps = 1000
eval_record_threshold = 5000
eval_record_steps = 200 # should be larger than checkpoint_steps? otherwise would duplicate
train_record_steps = 200
num_ml_epoch = 0
num_epochs = 10
batch_size = 50 # orig:32
## data source
source_train = os.path.join(DATASET_PATH, 'train', 'train_article.txt')
target_train = os.path.join(DATASET_PATH, 'train', 'train_summary.txt')
source_valid = os.path.join(DATASET_PATH, 'train', 'test_article.txt')
target_valid = os.path.join(DATASET_PATH, 'train', 'test_summary.txt')
source_test = os.path.join(DATASET_PATH, 'train', 'test_article.txt')
sum_dict = os.path.join(DATASET_PATH, 'train', 'dict.txt')
doc_dict = sum_dict
min_cnt = 20 # words whose occurred less than min_cnt are encoded as <UNK>.
# for char
article_minlen = 90
article_maxlen = 115 # Maximum number of words in a sentence. alias = T.
summary_minlen = 15
summary_maxlen = 22 # Maximum number of words in a sentence. alias = T.
'''
# for word
article_minlen = 45
article_maxlen = 65 # Maximum number of words in a sentence. alias = T.
summary_minlen = 5
summary_maxlen = 13 # Maximum number of words in a sentence. alias = T.
'''
## training parameter
sinusoid = False # If True, use sinusoid. If false, positional embedding.
hidden_units = 512 # alias = C # orig: 512
ffw_unit = 2048 # orig: 2048
num_blocks = 3 # number of encoder/decoder blocks
num_heads = 4
lr = 3e-6 # ml: 0.0001
max_reward_diff = 1.5 # upper & lower bound for reward difference (for rl)
dropout_rate = 0.1
eta_init = 0.95
maxgradient = 1000
class hknews_Hyperparams: # for hknews char data
## log path; frequency
logdir = 'logdir' # log directory
tb_dir = 'tbdir'
checkpoint_steps = 1000
eval_record_threshold = 5000
eval_record_steps = 200 # should be larger than checkpoint_steps? otherwise would duplicate
train_record_steps = 200
num_ml_epoch = 60
num_epochs = num_ml_epoch
batch_size = 32 # orig:32
## data source
source_train = os.path.join(DATASET_PATH, 'train', 'train_content.txt')
target_train = os.path.join(DATASET_PATH, 'train', 'train_title.txt')
source_valid = os.path.join(DATASET_PATH, 'train', 'test_content.txt')
target_valid = os.path.join(DATASET_PATH, 'train', 'test_title.txt')
source_test = os.path.join(DATASET_PATH, 'train', 'test_content.txt')
sum_dict = os.path.join(DATASET_PATH, 'train', 'full_dict.txt')
doc_dict = sum_dict
min_cnt = 20 # words whose occurred less than min_cnt are encoded as <UNK>.
''' char: '''
min_cnt = 20 # words whose occurred less than min_cnt are encoded as <UNK>.
article_minlen = 100
article_maxlen = 400 # Maximum number of words in a sentence. alias = T.
summary_minlen = 5
summary_maxlen = 23 # Maximum number of words in a sentence. alias = T.
''' word:
min_cnt = 20 # words whose occurred less than min_cnt are encoded as <UNK>.
article_minlen = 50
article_maxlen = 700 # Maximum number of words in a sentence. alias = T.
summary_minlen = 4
summary_maxlen = 15 # Maximum number of words in a sentence. alias = T.
'''
## training parameter
sinusoid = False # If True, use sinusoid. If false, positional embedding.
hidden_units = 512 # alias = C # orig: 512
ffw_unit = 2048 # orig: 2048
num_blocks = 3 # number of encoder/decoder blocks
num_heads = 8
lr = 0.0001
dropout_rate = 0.1
eta_init = 0.0
maxgradient = 1000