forked from epicosy/devign
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configs.py
150 lines (107 loc) · 3.05 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import json
import torch
class Config(object):
def __init__(self, config, file_path="configs.json"):
with open(file_path) as config_file:
self._config = json.load(config_file)
self._config = self._config.get(config)
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
def get_property(self, property_name):
return self._config.get(property_name)
def get_device(self):
return self.device
def all(self):
return self._config
class Create(Config):
def __init__(self):
super().__init__('create')
@property
def filter_column_value(self):
return self.get_property('filter_project')
@property
def slice_size(self):
return self.get_property('slice_size')
@property
def joern_cli_dir(self):
return self.get_property('joern_cli_dir')
class Data(Config):
def __init__(self, config):
super().__init__(config)
@property
def cpg(self):
return self.get_property('cpg')
@property
def raw(self):
return self.get_property('raw')
@property
def input(self):
return self.get_property('input')
@property
def model(self):
return self.get_property('model')
@property
def tokens(self):
return self.get_property('tokens')
@property
def w2v(self):
return self.get_property('w2v')
class Paths(Data):
def __init__(self):
super().__init__('paths')
@property
def joern(self):
return self.get_property('joern')
class Files(Data):
def __init__(self):
super().__init__('files')
@property
def tokens(self):
return self.get_property('tokens')
@property
def w2v(self):
return self.get_property('w2v')
class Embed(Config):
def __init__(self):
super().__init__('embed')
@property
def nodes_dim(self):
return self.get_property('nodes_dim')
@property
def w2v_args(self):
return self.get_property('word2vec_args')
@property
def edge_type(self):
return self.get_property('edge_type')
class Process(Config):
def __init__(self):
super().__init__('process')
@property
def epochs(self):
return self.get_property('epochs')
@property
def patience(self):
return self.get_property('patience')
@property
def batch_size(self):
return self.get_property('batch_size')
@property
def dataset_ratio(self):
return self.get_property('dataset_ratio')
@property
def shuffle(self):
return self.get_property('shuffle')
class Devign(Config):
def __init__(self):
super().__init__('devign')
@property
def learning_rate(self):
return self.get_property('learning_rate')
@property
def weight_decay(self):
return self.get_property('weight_decay')
@property
def loss_lambda(self):
return self.get_property('loss_lambda')
@property
def model(self):
return self.get_property('model')