-
Notifications
You must be signed in to change notification settings - Fork 21
/
configs.py
225 lines (203 loc) · 7.4 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
import datetime
import os
class ModelConfigFactory():
@staticmethod
def create_model_config(args):
if args.dataset == 'assist2009':
return Assist2009Config(args).get_args()
elif args.dataset == 'assist2015':
return Assist2015Config(args).get_args()
elif args.dataset == 'statics2011':
return StaticsConfig(args).get_args()
elif args.dataset == 'synthetic':
return SyntheticConfig(args).get_args()
elif args.dataset == 'fsai':
return FSAIConfig(args).get_args()
else:
raise ValueError("The '{}' is not available".format(args.dataset))
class ModelConfig():
def __init__(self, args):
self.default_setting = self.get_default_setting()
self.init_time = datetime.datetime.now().strftime("%Y-%m-%dT%H%M")
self.args = args
self.args_dict = vars(self.args)
for arg in self.args_dict.keys():
self._set_attribute_value(arg, self.args_dict[arg])
self.set_result_log_dir()
self.set_checkpoint_dir()
self.set_tensorboard_dir()
def get_args(self):
return self.args
def get_default_setting(self):
default_setting = {}
return default_setting
def _set_attribute_value(self, arg, arg_value):
self.args_dict[arg] = arg_value \
if arg_value is not None \
else self.default_setting.get(arg)
def _get_model_config_str(self):
model_config = 'b' + str(self.args.batch_size) \
+ '_m' + str(self.args.memory_size) \
+ '_q' + str(self.args.key_memory_state_dim) \
+ '_qa' + str(self.args.value_memory_state_dim) \
+ '_f' + str(self.args.summary_vector_output_dim)
return model_config
def set_result_log_dir(self):
result_log_dir = os.path.join(
'./results',
self.args.dataset,
self._get_model_config_str(),
self.init_time
)
self._set_attribute_value('result_log_dir', result_log_dir)
def set_checkpoint_dir(self):
checkpoint_dir = os.path.join(
'./models',
self.args.dataset,
self._get_model_config_str(),
self.init_time
)
self._set_attribute_value('checkpoint_dir', checkpoint_dir)
def set_tensorboard_dir(self):
tensorboard_dir = os.path.join(
'./tensorboard',
self.args.dataset,
self._get_model_config_str(),
self.init_time
)
self._set_attribute_value('tensorboard_dir', tensorboard_dir)
class Assist2009Config(ModelConfig):
def get_default_setting(self):
default_setting = {
# training setting
'n_epochs': 50,
'batch_size': 32,
'train': True,
'show': True,
'learning_rate': 0.003,
'max_grad_norm': 10.0,
'use_ogive_model': False,
# dataset param
'seq_len': 200,
'n_questions': 110,
'data_dir': './data/assist2009_updated',
'data_name': 'assist2009_updated',
# DKVMN param
'memory_size': 50,
'key_memory_state_dim': 50,
'value_memory_state_dim': 100,
'summary_vector_output_dim': 50,
# parameter for the SA Network and KCD network
'student_ability_layer_structure': None,
'question_difficulty_layer_structure': None,
'discimination_power_layer_structure': None
}
return default_setting
class Assist2015Config(ModelConfig):
def get_default_setting(self):
default_setting = {
# training setting
'n_epochs': 50,
'batch_size': 32,
'train': True,
'show': True,
'learning_rate': 0.003,
'max_grad_norm': 10.0,
'use_ogive_model': False,
# dataset param
'seq_len': 200,
'n_questions': 100,
'data_dir': './data/assist2015',
'data_name': 'assist2015',
# DKVMN param
'memory_size': 50,
'key_memory_state_dim': 50,
'value_memory_state_dim': 100,
'summary_vector_output_dim': 50,
# parameter for the SA Network and KCD network
'student_ability_layer_structure': None,
'question_difficulty_layer_structure': None,
'discimination_power_layer_structure': None
}
return default_setting
class StaticsConfig(ModelConfig):
def get_default_setting(self):
default_setting = {
# training setting
'n_epochs': 50,
'batch_size': 32,
'train': True,
'show': True,
'learning_rate': 0.003,
'max_grad_norm': 10.0,
'use_ogive_model': False,
# dataset param
'seq_len': 200,
'n_questions': 1223,
'data_dir': './data/STATICS',
'data_name': 'STATICS',
# DKVMN param
'memory_size': 50,
'key_memory_state_dim': 50,
'value_memory_state_dim': 100,
'summary_vector_output_dim': 50,
# parameter for the SA Network and KCD network
'student_ability_layer_structure': None,
'question_difficulty_layer_structure': None,
'discimination_power_layer_structure': None
}
return default_setting
class SyntheticConfig(ModelConfig):
def get_default_setting(self):
default_setting = {
# training setting
'n_epochs': 50,
'batch_size': 32,
'train': True,
'show': True,
'learning_rate': 0.003,
'max_grad_norm': 10.0,
'use_ogive_model': False,
# dataset param
'seq_len': 50,
'n_questions': 50,
'data_dir': './data/synthetic',
'data_name': 'synthetic',
# DKVMN param
'memory_size': 50,
'key_memory_state_dim': 50,
'value_memory_state_dim': 100,
'summary_vector_output_dim': 50,
# parameter for the SA Network and KCD network
'student_ability_layer_structure': None,
'question_difficulty_layer_structure': None,
'discimination_power_layer_structure': None
}
return default_setting
class FSAIConfig(ModelConfig):
def get_default_setting(self):
default_setting = {
# training setting
'n_epochs': 50,
'batch_size': 32,
'train': True,
'show': True,
'learning_rate': 0.003,
'max_grad_norm': 10.0,
'use_ogive_model': False,
# dataset param
'seq_len': 50,
'n_questions': 2266,
'data_dir': './data/fsaif1tof3',
'data_name': 'fsaif1tof3',
# DKVMN param
'memory_size': 50,
'key_memory_state_dim': 50,
'value_memory_state_dim': 100,
'summary_vector_output_dim': 50,
# parameter for the SA Network and KCD network
'student_ability_layer_structure': None,
'question_difficulty_layer_structure': None,
'discimination_power_layer_structure': None
}
return default_setting