Esempio n. 1
0
def run_yaml(path):
    import sys
    sys.path.append('..')
    from pylearn2.config import yaml_parse
    from utils.common import notify

    with open(path) as yaml_file:
        yaml = yaml_file.read()

    network = yaml_parse.load(yaml)
    network.main_loop()
    notify()
Esempio n. 2
0
    # create dictionary with hyper parameters
    hyper_params = {'model': yp.parse_to_yaml(mod), 'path': yp.parse_to_yaml(path),
                    'weight_decay_coeffs': weight_decay_coeffs, 'pkl_filename': pkl_filename}

    # fill the yaml skelton with hyperparameters
    yaml_string = default_string % hyper_params

    # saving the yaml for later analysis
    yaml_path = join(config.path_for_storing, timestamp+'generated_'+str(i)+'.yaml')
    with open(yaml_path, 'w') as g:
        g.write(yaml_string)

    try:
        # create the model based on a yaml
        network = yaml_parse.load(yaml_string)
        print t.bold_magenta('NETWORK'), type(network)

        # train the model
        network.main_loop()
    except BaseException as e:
        # if exception was thrown save yaml of a model that generated that exception
        with open('0000'+str(i)+'.yaml', 'w') as YAML_FILE:
            YAML_FILE.write(yaml_string)
        #  write down errors description to a file
        with open('0000'+str(i)+'_error', 'w') as ERROR_FILE:
            ERROR_FILE.write(traceback.format_exc())

# play a melody so everyone knows the testing has finished
notify()