forked from tommasolevato/CNN-Classification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hyper_parameters_test.py
44 lines (31 loc) · 978 Bytes
/
hyper_parameters_test.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
# coding=utf-8
__author__ = 'Tommaso Levato'
import yaml
import numpy
import os
import pylearn2
import sys
from hyper_parameters_parser import Parser
from pylearn2.config import yaml_parse
from pylearn2.datasets.mjsynth.mjsynth import MJSYNTH
from pylearn2.datasets.mjsynth.config import Config
def output_file_string(params):
string = []
for key in params.keys():
string.append(key + ": " + str(params[key]))
return ' '.join(string)
p = Parser()
while p.has_other_configurations():
with open(Config.getYamlFilename(), 'r') as f:
yaml_file = f.read()
hyper_params = p.get_next_configuration()
outputFile = open('tests/' + p.get_num_configuration().__str__(), 'w')
sys.stdout = outputFile
sys.stderr = outputFile
yaml_file = yaml_file % (hyper_params)
print yaml_file
train = yaml_parse.load(yaml_file)
try:
train.main_loop()
except Exception as e:
print e