-
Notifications
You must be signed in to change notification settings - Fork 94
/
config.py
86 lines (70 loc) · 2 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
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
"""
Configuration for each dataset
"""
import os
class CONFIG:
"""
des:
data_dir
checkpoint_dir: data/model
input_parser: libsvm/csv/tfrecord
padded_shape: if varlen feature included, pad shape is needed for padded_batch
"""
CHECKPOINT_DIR = './{}_checkpoint/{}'
DATA_MAP = {
'census': '{}.csv',
'frappe': 'frappe.{}.libfm',
'amazon': 'amazon_{}.tfrecords'
}
PARSER_MAP = {
'census': 'csv',
'frappe': 'libsvm',
'amazon': 'tfrecord'
}
TYPE_MAP = {
'census': 'dense',
'frappe': 'sparse',
'amazon': 'varlen-sparse'
}
PADDED_SHAPE = {
'census': None,
'frappe': None,
'amazon': ({
'reviewer_id': [],
'hist_item_list': [None],
'hist_category_list':[None],
'hist_length': [],
'item': [],
'item_category':[],
},[1])
}
def __init__(self, model_name, data_name):
self.model_name = model_name
self.data_name = data_name
self.input_check()
def input_check(self):
if self.data_name not in CONFIG.DATA_MAP.keys():
raise Exception( 'Currenlty only [{}] is supported'.format( ' | '.join( CONFIG.DATA_MAP.keys() ) ) )
@property
def data_dir(self):
return os.path.join('data', self.data_name, CONFIG.DATA_MAP[self.data_name])
@property
def checkpoint_dir(self):
return CONFIG.CHECKPOINT_DIR.format(self.data_name, self.model_name)
@property
def input_parser(self):
return CONFIG.PARSER_MAP[self.data_name]
@property
def pad_shape(self):
return CONFIG.PADDED_SHAPE[self.data_name]
@property
def input_type(self):
return CONFIG.TYPE_MAP[self.data_name]
def get_constZ(self):
# get const for dataset: defined in const/dataset
pass
MODEL_PARAMS = {
'batch_size': 512,
'num_epochs': 5000,
'buffer_size': 512
}