-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.py
59 lines (37 loc) · 1.43 KB
/
main.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
'''
@Author: Gordon Lee
@Date: 2019-08-12 21:05:31
@LastEditors: Gordon Lee
@LastEditTime: 2019-08-16 16:45:07
@Description:
'''
import fire
import models
from config import Config
from models.TextCNN import ModelCNN
from models.TextAttnBiLSTM import ModelAttnBiLSTM
def run(**kwargs):
global_opt = Config()
for k,v in kwargs.items():
if getattr(global_opt, k, 'KeyError') != 'KeyError':
setattr(global_opt, k, v)
if global_opt.use_model == 'TextCNN':
model_opt = models.TextCNN.ModelConfig()
for k,v in kwargs.items():
if getattr(model_opt, k,'KeyError') != 'KeyError':
setattr(model_opt, k, v)
if global_opt.status == 'train':
models.TextCNN.train_eval(model_opt)
elif global_opt.status == 'test':
models.TextCNN.test(model_opt)
elif global_opt.use_model == 'TextAttnBiLSTM':
model_opt = models.TextAttnBiLSTM.ModelConfig()
for k,v in kwargs.items():
if getattr(model_opt, k,'KeyError') != 'KeyError':
setattr(model_opt, k, v)
if global_opt.status == 'train':
models.TextAttnBiLSTM.train_eval(model_opt)
elif global_opt.status == 'test':
models.TextAttnBiLSTM.test(model_opt)
if __name__ == "__main__":
fire.Fire()