Example #1
0
def main(unused_args):
    require_flag('billboard_path')

    feature_type = FLAGS.feature_type
    cache_filename = '../billboard-datasets-%s.cpkl' % feature_type
    if os.path.exists(cache_filename):
        datasets = load_datasets(cache_filename)
    else:
        datasets = billboard.read_billboard_datasets(FLAGS.billboard_path,
                                                     feature_type=FLAGS.feature_type)
        dump_datasets(datasets, cache_filename)

    # grid = {
    #     'n_hidden': [300, 800, 1300, 1800, 2300, 2800, 3300],
    #     'n_steps': [200],
    #     'spectral_radius': [1.],
    #     'connectivity': [.01, .0001],
    #     'max_leakage': [.99],
    #     'min_leakage': [.3],
    #     'ridge_beta': [0, .5],
    #     'input_scaling': [.2],
    #     'input_shift': [0],
    # }

    grid = {
        'n_hidden': [2000],
        'n_steps': [200],
        'spectral_radius': [1.],
        'connectivity': [.01],
        'max_leakage': [.99],
        'min_leakage': [.3],
        'ridge_beta': [.5],
        'input_scaling': [.2],
        'input_shift': [0],
    }
    grid_product = list(dict_product(grid))
    #random.shuffle(grid_product)

    for config in grid_product:

        config['n_inputs'] = datasets.train.feature_reader.num_features
        config['n_outputs'] = datasets.train.label_reader.num_labels

        print '\n%s' % config

        if FLAGS.backend == 'numpy':
            numpy_eval(datasets, config)
        elif FLAGS.backend == 'tensorflow':
            tensorflow_eval(datasets, config)
        else:
            print 'unknown backend'