-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhparams.py
133 lines (111 loc) · 5.9 KB
/
hparams.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
import argparse
class Hparams:
parser = argparse.ArgumentParser()
# prepro
parser.add_argument('--vocab_size', default=38370, type=int)
#
# train
## files
parser.add_argument('--train1', default='data/train_src.txt',
help="german training segmented data")
parser.add_argument('--train2', default='data/train_tgt.txt',
help="english training segmented data")
parser.add_argument('--eval1', default='data/valid_src.txt',
help="german evaluation segmented data")
parser.add_argument('--eval2', default='data/valid_tgt.txt',
help="english evaluation segmented data")
#parser.add_argument('--eval3', default='iwslt2016/prepro/eval.en',
# help="english evaluation unsegmented data")
## vocabulary path
parser.add_argument('--vocab', default='data/word_dict_zhihu.npy',
help="vocabulary file path")
# training scheme
parser.add_argument('--batch_size', default=64, type=int)
parser.add_argument('--eval_batch_size', default=64, type=int)
parser.add_argument('--lr', default=0.001, type=float, help="learning rate")
parser.add_argument('--warmup_steps', default=4000, type=int)#大概10个epoch
parser.add_argument('--logdir', default="log/1", help="log directory")
parser.add_argument('--num_epochs', default=150, type=int)
parser.add_argument('--evaldir', default="eval/1", help="evaluation dir")
# model
parser.add_argument('--d_model', default=512, type=int,
help="hidden dimension of encoder/decoder")
parser.add_argument('--d_ff', default=1024,type=int,
help="hidden dimension of feedforward layer")
parser.add_argument('--num_blocks', default=3, type=int,
help="number of encoder/decoder blocks")
parser.add_argument('--num_heads', default=4, type=int,
help="number of attention heads")
parser.add_argument('--maxlen1', default=6, type=int,
help="maximum length of a source sequence")
#源语句的最大长度
parser.add_argument('--maxlen2', default=101, type=int,
help="maximum length of a target sequence")
#目标语句的最大长度
parser.add_argument('--dropout_rate', default=0.3, type=float)
parser.add_argument('--smoothing', default=0.1, type=float,
help="label smoothing rate")
# test
parser.add_argument('--test1', default='data/test_src.txt',
help="german test segmented data")
parser.add_argument('--test2', default='data/test_tgt.txt',
help="english test data")
parser.add_argument('--ckpt', default='log/1', help="checkpoint file path")
parser.add_argument('--test_batch_size', default=64, type=int)
parser.add_argument('--testdir', default="test/1", help="test result dir")
"""
class Hparams:
parser = argparse.ArgumentParser()
# prepro
parser.add_argument('--vocab_size', default=32000, type=int)
#
# train
## files
parser.add_argument('--train1', default='data/train_src.txt',
help="german training segmented data")
parser.add_argument('--train2', default='data/train_tgt.txt',
help="english training segmented data")
parser.add_argument('--eval1', default='data/valid_src.txt',
help="german evaluation segmented data")
parser.add_argument('--eval2', default='data/valid_tgt.txt',
help="english evaluation segmented data")
#parser.add_argument('--eval3', default='iwslt2016/prepro/eval.en',
# help="english evaluation unsegmented data")
## vocabulary path
parser.add_argument('--vocab', default='data/word_dict_zhihu.npy',
help="vocabulary file path")
# training scheme
parser.add_argument('--batch_size', default=64, type=int)
parser.add_argument('--eval_batch_size', default=64, type=int)
parser.add_argument('--lr', default=0.0003, type=float, help="learning rate")
parser.add_argument('--warmup_steps', default=4000, type=int)
parser.add_argument('--logdir', default="log/1", help="log directory")
parser.add_argument('--num_epochs', default=20, type=int)
parser.add_argument('--evaldir', default="eval/1", help="evaluation dir")
# model
parser.add_argument('--d_model', default=512, type=int,
help="hidden dimension of encoder/decoder")
parser.add_argument('--d_ff', default=2048, type=int,
help="hidden dimension of feedforward layer")
parser.add_argument('--num_blocks', default=6, type=int,
help="number of encoder/decoder blocks")
parser.add_argument('--num_heads', default=8, type=int,
help="number of attention heads")
parser.add_argument('--maxlen1', default=5, type=int,
help="maximum length of a source sequence")
#源语句的最大长度
parser.add_argument('--maxlen2', default=100, type=int,
help="maximum length of a target sequence")
#目标语句的最大长度
parser.add_argument('--dropout_rate', default=0.3, type=float)
parser.add_argument('--smoothing', default=0.1, type=float,
help="label smoothing rate")
# test
parser.add_argument('--test1', default='data/test_src.txt',
help="german test segmented data")
parser.add_argument('--test2', default='data/test_tgt.txt',
help="english test data")
parser.add_argument('--ckpt', help="checkpoint file path")
parser.add_argument('--test_batch_size', default=128, type=int)
parser.add_argument('--testdir', default="test/1", help="test result dir")
"""