-
Notifications
You must be signed in to change notification settings - Fork 8
/
configs.py
58 lines (48 loc) · 1.4 KB
/
configs.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
import os
from version import version
output_dir = os.path.join('output', version)
os.makedirs(output_dir, exist_ok=True)
gigaword_path = 'data/gigaword'
special_symbols = ['<target>', '<unkn>', '<pad>', '<eos>']
class DefaultConfig(object):
vocab_size = 10**6 + len(special_symbols)
max_grad_norm = 5
num_senses = 4
init_scale = 0.1
learning_rate = 0.1
assume_same_lengths = True
sampled_softmax = True
optimized_batches = True
max_stagnant_count = 10
max_epoch = 100
# max_epoch = 1 # for debugging
class SmallConfig(DefaultConfig):
hidden_size = 100
emb_dims = 10
class H256P64(DefaultConfig):
hidden_size = 256
emb_dims = 64
class LargeConfig(DefaultConfig):
hidden_size = 512
emb_dims = 128
class GoogleConfig(DefaultConfig):
hidden_size = 2048
emb_dims = 512
class TestConfig(DefaultConfig):
"""Tiny config, for testing."""
hidden_size = 2
max_epoch = 1
batch_size = 20
def get_config(FLAGS):
if FLAGS.model == "small":
return SmallConfig()
elif FLAGS.model == "h256p64":
return H256P64()
elif FLAGS.model == "large" or FLAGS.model == "h512p128":
return LargeConfig()
elif FLAGS.model == "google" or FLAGS.model == "h2048p512":
return GoogleConfig()
elif FLAGS.model == "test":
return TestConfig()
else:
raise ValueError("Invalid model: %s", FLAGS.model)