-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_config.py
144 lines (117 loc) · 4.12 KB
/
model_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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
from ast import Param
from easydict import EasyDict
from sklearn.model_selection import ParameterGrid
def get_model_config(model_name):
if model_name == 'Linear':
return Linear_config()
elif model_name == 'Ridge':
return Ridge_config()
elif model_name == 'RF':
return RF_config()
elif model_name == 'XGB':
return XGB_config()
elif model_name == 'LGB':
return LGB_config()
elif model_name == 'MLP':
return MLP_config()
elif model_name == 'MeshNet':
return MeshNet_config()
elif model_name == 'GIN':
return GIN_config()
elif model_name == 'ExpC':
return ExpC_config()
elif model_name == 'Graphormer':
return Graphormer_config()
else:
return NotImplementedError(model_name)
class ParameterList:
def __init__(self, model_args, basic_args) -> None:
self.iter_list = []
for k, v in model_args.items():
self.iter_list.extend([(k, val) for val in v])
self.basic_args = basic_args
def __len__(self):
return len(self.iter_list)
def __iter__(self):
yield self.basic_args # Add a default config.
for k, v in self.iter_list:
args = self.basic_args.copy()
args[k] = v
yield args
def Linear_config():
args = {}
return ParameterGrid(args)
def Ridge_config():
args = {'alpha': [1e-3, 1e-2, 1e-1, 1.0]}
return ParameterGrid(args)
def RF_config():
args = {
'n_estimators': [10, 25, 50, 75, 100],
'criterion': ['squared_error', 'absolute_error', 'poisson'],
'min_samples_split': [2, 8, 32]
}
return ParameterGrid(args)
def XGB_config():
args = {
'n_estimators': [10, 25, 50, 75, 100],
'max_depth': [4, 16, 64],
'reg_alpha': [0.0, 1e-3, 1e-2, 1e-1, 1.0],
'reg_lambda': [0.0, 1e-3, 1e-2, 1e-1, 1.0],
}
return ParameterGrid(args)
def LGB_config():
args = {
'n_estimators': [10, 25, 50, 75, 100],
'max_depth': [4, 16, 64],
'reg_alpha': [0.0, 1e-3, 1e-2, 1e-1, 1.0],
'reg_lambda': [0.0, 1e-3, 1e-2, 1e-1, 1.0],
}
return ParameterGrid(args)
def MLP_config():
args = {
'batch_size': [8, 32, 128, 512],
'lr': [1e-5, 1e-4, 1e-3, 1e-2],
'hidden': [128, 256, 512],
'output': [1],
'layers': [2, 3, 4, 5],
}
basic = {'batch_size': 128, 'lr': 1e-3, 'hidden': 128, 'output': 1, 'layers': 2, 'dropout': 0.1}
return ParameterList(args, basic)
def MeshNet_config():
args = {
'batch_size': [8, 32, 128, 512],
'lr': [1e-5, 1e-4, 1e-3, 1e-2],
'hidden': [128, 256, 512],
'output': [1],
'layers': [2, 3, 4, 5],
}
basic = {'batch_size': 128, 'lr': 1e-3, 'hidden': 128, 'output': 1, 'layers': 2, 'dropout': 0.1}
return ParameterList(args, basic)
def GIN_config():
args = {
'batch_size': [8, 32, 128, 512],
'lr': [1e-5, 1e-4, 1e-3, 1e-2],
'hidden': [128, 256, 512],
'layers': [2, 3, 4, 5],
'JK': ['last', 'cat', 'max', 'lstm'],
}
basic = {'batch_size': 128, 'lr': 1e-3, 'hidden': 128, 'output': 1, 'layers': 2, 'dropout': 0.1, 'eps': 1e-5, 'JK': 'max'}
return ParameterList(args, basic)
def ExpC_config():
args = {
'batch_size': [8, 32, 128, 512],
'lr': [1e-5, 1e-4, 1e-3, 1e-2],
'hidden': [128, 256, 512],
'layers': [2, 3, 4, 5]
}
basic = {'batch_size': 128, 'lr': 1e-3, 'hidden': 128, 'output': 1, 'layers': 2, 'dropout': 0.1, 'JK': 'M', 'pooling': 'M', 'exp_nonlinear': 'ELU', 'exp_n': 2, 'exp_bn': 'Y'}
return ParameterList(args, basic)
def Graphormer_config():
args = {
'batch_size': [8, 32, 128, 512],
'lr': [1e-5, 1e-4, 1e-3, 1e-2],
'hidden': [128, 256, 512],
'layers': [2],
}
basic = {'batch_size': 128, 'lr': 1e-3, 'hidden': 128, 'output': 1, 'layers': 2, 'dropout': 0.1, 'head_size': 32, 'weight_decay': 1e-5, 'warmup_updates': 60_000, 'tot_updates': 1_000_000, 'peak_lr': 2e-4, 'end_lr': 1e-9, 'edge_type': 'multi_Hop', 'multi_hop_max_dist': 5}
return ParameterList(args, basic)