-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils_gm.py
72 lines (64 loc) · 3.02 KB
/
utils_gm.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
import sys
PATH_TO_CIFAR = "./cifar_gm/"
sys.path.append(PATH_TO_CIFAR)
# import train as cifar_train
class Namespace():
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
class dotdict(dict):
""" dot.notation access to dictionary attributes """
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
def _get_config(args):
print('refactored get_config')
import hyperparameters.vgg11_cifar10_baseline as cifar10_vgg_hyperparams # previously vgg_hyperparams
import hyperparameters.vgg11_half_cifar10_baseline as cifar10_vgg_hyperparams_half
import hyperparameters.vgg11_doub_cifar10_baseline as cifar10_vgg_hyperparams_doub
import hyperparameters.vgg11_quad_cifar10_baseline as cifar10_vgg_hyperparams_quad
import hyperparameters.resnet18_nobias_cifar10_baseline as cifar10_resnet18_nobias_hyperparams
import hyperparameters.resnet18_nobias_nobn_cifar10_baseline as cifar10_resnet18_nobias_nobn_hyperparams
import hyperparameters.mlpnet_cifar10_baseline as mlpnet_hyperparams
config = None
second_config = None
if args.dataset.lower() == 'cifar10':
if args.model_name == 'mlpnet':
config = mlpnet_hyperparams.config
elif args.model_name == 'vgg11_nobias':
config = cifar10_vgg_hyperparams.config
elif args.model_name == 'vgg11_half_nobias':
config = cifar10_vgg_hyperparams_half.config
elif args.model_name == 'vgg11_doub_nobias':
config = cifar10_vgg_hyperparams_doub.config
elif args.model_name == 'vgg11_quad_nobias':
config = cifar10_vgg_hyperparams_quad.config
elif args.model_name == 'resnet18_nobias':
config = cifar10_resnet18_nobias_hyperparams.config
elif args.model_name == 'resnet18_nobias_nobn':
config = cifar10_resnet18_nobias_nobn_hyperparams.config
else:
raise NotImplementedError
if args.second_model_name is not None:
if 'vgg' in args.second_model_name:
if 'half' in args.second_model_name:
second_config = cifar10_vgg_hyperparams_half.config
elif 'doub' in args.second_model_name:
second_config = cifar10_vgg_hyperparams_doub.config
elif 'quad' in args.second_model_name:
second_config = cifar10_vgg_hyperparams_quad.config
elif args.second_model_name == 'vgg11_nobias':
second_config = cifar10_vgg_hyperparams.config
else:
raise NotImplementedError
elif 'resnet' in args.second_model_name:
if args.second_model_name == 'resnet18_nobias':
second_config= cifar10_resnet18_nobias_hyperparams.config
elif args.second_model_name == 'resnet18_nobias_nobn':
config = cifar10_resnet18_nobias_nobn_hyperparams.config
else:
raise NotImplementedError
else:
second_config = config
return config, second_config
def isnan(x):
return x != x