-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.py
41 lines (35 loc) · 1.65 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
import os
import yaml
class Config(object):
def __init__(self, config_path):
assert os.path.exists(config_path), "ERROR: Config File doesn't exist"
with open(config_path, 'r') as f:
self._yaml = f.read()
self._dict = yaml.load(self._yaml)
def __getattr__(self, name):
if self._dict.get(name) is not None:
return self._dict[name]
if DEFAULT_CONFIG.get(name) is not None:
return DEFAULT_CONFIG[name]
return None
def print(self):
print('Model configurations:')
print('---------------------------------')
print(self._yaml)
print('')
print('---------------------------------')
print('')
DEFAULT_CONFIG = {
'SEED': 10, # random seed
'GPU': [5], # list of gpu ids
'LR': 0.0001, # learning rate
'BETA1': 0.0, # adam optimizer beta1
'BETA2': 0.9, # adam optimizer beta2
'BATCH_SIZE': 8, # input batch size for training
'INPUT_SIZE': 256, # input image size for training 0 for original size
'SAVE_INTERVAL': 1000, # how many iterations to wait before saving model (0: never)
'SAMPLE_INTERVAL': 1000, # how many iterations to wait before sampling (0: never)
'SAMPLE_SIZE': 12, # number of images to sample
'EVAL_INTERVAL': 0, # how many iterations to wait before model evaluation (0: never)
'LOG_INTERVAL': 10, # how many iterations to wait before logging training status (0: never)
}