-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathconfig.py
60 lines (45 loc) · 1.34 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
# -*- coding: utf-8 -*-
class Config():
# ELMo
elmo_options_file = "./data/elmo/elmo_2x2048_256_2048cnn_1xhighway_options.json"
elmo_weight_file = "./data/elmo/elmo_2x2048_256_2048cnn_1xhighway_weights.hdf5"
elmo_dim = 512
# Bert
bert_path = './data/bert/'
bert_dim = 768
# glove
vocab_size = 18766
glove_dim = 300
glove_file = "./data/glove/glove_300d.npy"
word2id_file = "./data/glove/word2id.npy"
emb_method = 'glove' # bert/elmo/glove/
enc_method = 'CNN' # CNN/RNN/Transformer/mean
hidden_size = 200
out_size = 64
num_labels = 2
use_gpu = True
seed = 2020
gpu_id = 0
dropout = 0.5
epochs = 20
test_size = 0.1
lr = 1e-3
weight_decay = 1e-4
batch_size = 64
device = "cuda:0"
def parse(self, kwargs):
'''
user can update the default hyperparamter
'''
for k, v in kwargs.items():
if not hasattr(self, k):
raise Exception('opt has No key: {}'.format(k))
setattr(self, k, v)
print('*************************************************')
print('user config:')
for k, v in self.__class__.__dict__.items():
if not k.startswith('__'):
print("{} => {}".format(k, getattr(self, k)))
print('*************************************************')
Config.parse = parse
opt = Config()