-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrun_experiments.py
43 lines (33 loc) · 1.16 KB
/
run_experiments.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
import os
import yaml
import logging
import importlib
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
logging.getLogger('tensorflow').disabled = True
from cifar_training_tools import cifar_training, cifar_error_test
def print_dict(d, tabs=0):
tab = '\t'
for key in d:
if type(d[key]) == dict:
print(f"{tab*tabs}{key}:")
print_dict(d[key], tabs+1)
else:
print(f"{tab*tabs}{key}: {d[key]}")
print('\n' + '#' * 19)
print("TESTING FOR ERRORS!")
print('#' * 19)
stream = open('experiments.yaml', 'r')
for exp in yaml.safe_load_all(stream):
if 'skip_error_test' in exp and exp['skip_error_test']:
continue
model = getattr(importlib.import_module(exp['module']), exp['model'])
cifar_error_test(model(**exp['model_parameters']))
print("OK!")
print('\n' + '#' * 22)
print("MODEL TRAINING BEGINS!")
print('#' * 22)
stream = open('experiments.yaml', 'r')
for exp in yaml.safe_load_all(stream):
print(); print_dict(exp); print();
model = getattr(importlib.import_module(exp['module']), exp['model'])
cifar_training(model(**exp['model_parameters']), **exp['train_parameters'])