-
Notifications
You must be signed in to change notification settings - Fork 60
/
config.py
executable file
·120 lines (109 loc) · 3.89 KB
/
config.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
import logging
import time
import configparser
class _Config:
def __init__(self):
self._init_logging_handler()
self.cuda_device = 0
self.eos_m_token = 'EOS_M'
self.beam_len_bonus = 0.6
self.mode = 'unknown'
self.m = 'TSD'
self.prev_z_method = 'none'
self.dataset = 'unknown'
self.seed = 0
def init_handler(self, m):
init_method = {
'tsdf-camrest':self._camrest_tsdf_init,
'tsdf-kvret':self._kvret_tsdf_init
}
init_method[m]()
def _camrest_tsdf_init(self):
self.beam_len_bonus = 0.5
self.prev_z_method = 'separate'
self.vocab_size = 800
self.embedding_size = 50
self.hidden_size = 50
self.split = (3, 1, 1)
self.lr = 0.003
self.lr_decay = 0.5
self.vocab_path = './vocab/vocab-camrest.pkl'
self.data = './data/CamRest676/CamRest676.json'
self.entity = './data/CamRest676/CamRestOTGY.json'
self.db = './data/CamRest676/CamRestDB.json'
self.glove_path = './data/glove/glove.6B.50d.txt'
self.batch_size = 32
self.z_length = 8
self.degree_size = 5
self.layer_num = 1
self.dropout_rate = 0.5
self.epoch_num = 100 # triggered by early stop
self.rl_epoch_num = 1
self.cuda = False
self.spv_proportion = 100
self.max_ts = 40
self.early_stop_count = 3
self.new_vocab = True
self.model_path = './models/camrest.pkl'
self.result_path = './results/camrest-rl.csv'
self.teacher_force = 100
self.beam_search = False
self.beam_size = 10
self.sampling = False
self.use_positional_embedding = False
self.unfrz_attn_epoch = 0
self.skip_unsup = False
self.truncated = False
self.pretrain = False
def _kvret_tsdf_init(self):
self.prev_z_method = 'separate'
self.intent = 'all'
self.vocab_size = 1400
self.embedding_size = 50
self.hidden_size = 50
self.split = None
self.lr = 0.003
self.lr_decay = 0.5
self.vocab_path = './vocab/vocab-kvret.pkl'
self.train = './data/kvret/kvret_train_public.json'
self.dev = './data/kvret/kvret_dev_public.json'
self.test = './data/kvret/kvret_test_public.json'
self.entity = './data/kvret/kvret_entities.json'
self.glove_path = './data/glove/glove.6B.50d.txt'
self.batch_size = 32
self.degree_size = 5
self.z_length = 8
self.layer_num = 1
self.dropout_rate = 0.5
self.epoch_num = 100
self.rl_epoch_num = 2
self.cuda = False
self.spv_proportion = 100
self.alpha = 0.0
self.max_ts = 40
self.early_stop_count = 3
self.new_vocab = True
self.model_path = './models/kvret.pkl'
self.result_path = './results/kvret.csv'
self.teacher_force = 100
self.beam_search = False
self.beam_size = 10
self.sampling = False
self.use_positional_embedding = False
self.unfrz_attn_epoch = 0
self.skip_unsup = False
self.truncated = False
self.pretrain = False
def __str__(self):
s = ''
for k,v in self.__dict__.items():
s += '{} : {}\n'.format(k,v)
return s
def _init_logging_handler(self):
current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
stderr_handler = logging.StreamHandler()
file_handler = logging.FileHandler('./log/log_{}.txt'.format(current_time))
logging.basicConfig(handlers=[stderr_handler, file_handler])
logger = logging.getLogger()
logger.setLevel(logging.INFO)
global_config = _Config()