-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig_model.py
60 lines (49 loc) · 1.27 KB
/
config_model.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
"""Configurations of Transformer model
"""
import copy
import texar.torch as tx
random_seed = 1234
beam_width = 5
length_penalty = 0.6
hidden_dim = 400
emb = {
"name": "lookup_table",
"dim": hidden_dim,
"initializer": {
"type": "normal_",
"kwargs": {"mean": 0.0, "std": hidden_dim ** -0.5},
},
}
position_embedder_hparams = {"dim": hidden_dim}
encoder = {
"dim": hidden_dim,
"num_blocks": 3,
"multihead_attention": {
"num_heads": 8,
"num_units": hidden_dim,
"output_dim": hidden_dim
# See documentation for more optional hyperparameters
},
"initializer": {
"type": "variance_scaling_initializer",
"kwargs": {"factor": 1.0, "mode": "FAN_AVG", "uniform": True},
},
"poswise_feedforward": tx.modules.default_transformer_poswise_net_hparams(
input_dim=hidden_dim,
output_dim=hidden_dim
),
}
decoder = copy.deepcopy(encoder)
loss_label_confidence = 0.9
opt = {
"optimizer": {
"type": "Adam",
"kwargs": {"beta1": 0.9, "beta2": 0.997, "epsilon": 1e-9},
}
}
lr_config = {
"learning_rate_schedule": "constant.linear_warmup.rsqrt_decay.rsqrt_depth",
"lr_constant": 2 * (hidden_dim ** -0.5),
"static_lr": 1e-3,
"warmup_steps": 16000,
}