-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
55 lines (42 loc) · 1.31 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
# coding:utf8
import warnings
class DefaultConfig(object):
data_path = r'data/诡秘之主.txt'
# 是否有训练好的参数
# model_param_path = None
model_param_path = r'output/SiasemeCBOW0219_14_46_43.pth'
# 字典
word_dic = None
# 由字典的长度决定
input_dim = None
# 词嵌入的输输出维度
output_dim = 100
# 句子对齐的长度
sent_length = 32
# 正例集个数
n_pos = 2
# 反例集个数
n_neg = 5
# 学习参数设定
learning_rate = 0.0001 # initial learning rate
epochs = 5
# max_epoch = 10
# lr = 0.001 # initial learning rate
# lr_decay = 0.5 # when val_loss increase, lr = lr*lr_decay
# weight_decay = 0e-5 # 损失函数
# 保存文件名
output_file = None
def _parse(self, kwargs):
"""
根据字典kwargs 更新 config参数
"""
for k, v in kwargs.items():
if not hasattr(self, k):
warnings.warn("Warning: opt has not attribut %s" % k)
setattr(self, k, v)
# opt.device = t.device('cuda') if opt.use_gpu else t.device('cpu')
print('user config:')
for k, v in self.__class__.__dict__.items():
if not k.startswith('_'):
print(k, getattr(self, k))
opt = DefaultConfig()