Exemplo n.º 1
0
        numpy.random.seed(args.seed)
    from toupee import data
    from toupee import config 
    from toupee.mlp import sequential_model

    params = config.load_parameters(args.params_file)

    def arg_params(arg_value,param):
        if arg_value is not None:
            params.__dict__[param] = arg_value

    for arg, param in arg_param_pairings:
        arg_params(arg,param)
    original_params = copy.deepcopy(params)
    dataset = data.load_data(params.dataset,
                             pickled = params.pickled,
                             one_hot_y = params.one_hot,
                             join_train_and_valid = params.join_train_and_valid)
    method = params.method
    method.prepare(params,dataset)
    train_set = method.resampler.get_train()
    valid_set = method.resampler.get_valid()
    members = []
    intermediate_scores = []
    final_score = None
    for i in range(0,params.ensemble_size):
        print 'training member {0}'.format(i)
        members.append(method.create_member())
        ensemble = method.create_aggregator(params,members,train_set,valid_set)
        test_set_x, test_set_y = method.resampler.get_test()
        test_score = accuracy(ensemble,test_set_x,test_set_y)
        print 'Intermediate test accuracy: {0} %'.format(test_score * 100.)
Exemplo n.º 2
0
            if os.path.exists(dict_dir):
                params.dataset = dict_dir
            else:
                print("The desired dict_number doesn't exist!")

    def arg_params(arg_value, param):
        if arg_value is not None:
            params.__dict__[param] = arg_value

    for arg, param in arg_param_pairings:
        arg_params(arg, param)
    dataset = data.load_data(params.dataset,
                             pickled=params.pickled,
                             one_hot_y=params.one_hot,
                             join_train_and_valid=params.join_train_and_valid,
                             zca_whitening=params.zca_whitening,
                             testfile=args.testfile,
                             validfile=args.validfile,
                             trainfile=args.trainfile)
    method = params.method
    method.prepare(params, dataset)
    train_set = method.resampler.get_train()
    valid_set = method.resampler.get_valid()

    #selects the appropriate intermediate score: classification - accuracy; regression - euclidian_distance
    scorer = []
    scorer_name = []
    if params.classification == True:
        scorer.append(accuracy)
        scorer_name.append('accuracy')
    else:
Exemplo n.º 3
0
    from toupee import data
    from toupee import config 
    from toupee.mlp import sequential_model

    params = config.load_parameters(args.params_file)

    def arg_params(arg_value,param):
        if arg_value is not None:
            params.__dict__[param] = arg_value

    for arg, param in arg_param_pairings:
        arg_params(arg,param)
    original_params = copy.deepcopy(params)
    dataset = data.load_data(params.dataset,
                             pickled = params.pickled,
                             one_hot_y = params.one_hot,
                             join_train_and_valid = params.join_train_and_valid,
                             zca_whitening = params.zca_whitening)
    method = params.method
    method.prepare(params,dataset)
    train_set = method.resampler.get_train()
    valid_set = method.resampler.get_valid()
    members = []
    intermediate_scores = []
    final_score = None
    continue_learning = True
    for i in range(0,params.ensemble_size):
        print('training member {0}'.format(i))
        m = method.create_member()
        if m[0] is not None:
            members.append(m[:2])
Exemplo n.º 4
0
    arg_param_pairings = [
        (args.seed, 'random_seed'),
        (args.results_db, 'results_db'),
        (args.results_host, 'results_host'),
        (args.results_table, 'results_table'),
        (args.epochs, 'n_epochs'),
    ]
    from toupee import config
    params = config.load_parameters(args.params_file)

    def arg_params(arg_value, param):
        if arg_value is not None:
            params.__dict__[param] = arg_value

    for arg, param in arg_param_pairings:
        arg_params(arg, param)

    from toupee import data
    from toupee.mlp import MLP, test_mlp
    dataset = data.load_data(params.dataset,
                             resize_to=params.resize_data_to,
                             shared=False,
                             pickled=params.pickled,
                             center_and_normalise=params.center_and_normalise,
                             join_train_and_valid=params.join_train_and_valid)
    pretraining_set = data.make_pretraining_set(dataset, params.pretraining)
    mlp = test_mlp(dataset, params, pretraining_set=pretraining_set)
    if args.save_file is not None:
        dill.dump(mlp, open(args.save_file, "wb"))
Exemplo n.º 5
0
from toupee import data
import sys
import cPickle
import gzip
import os
import copy
import math
import numpy as np

if __name__ == '__main__':
    if len(sys.argv) > 2:
        dataset = sys.argv[1]
        fileName = sys.argv[2]
    else:
        raise Exception("need source and destination")
    dataset = data.load_data(dataset, pickled=False, shared=False)
    train, valid, test = dataset
    train_x, train_y = train
    valid_x, valid_y = valid
    test_x, test_y = test
    #    n_in = test_x.shape[1]
    #    params = { 'alpha': 0.0,
    #               'beta': 30.0,
    #               'gamma': 20.0,
    #               'sigma': 1,
    #               'pflip': 0.0,
    #               'translation': 3.0,
    #               'bilinear': True
    #             }
    #    t = data.GPUTransformer(sharedX(train_x),
    #                    x=int(math.sqrt(n_in)),
Exemplo n.º 6
0
        print "setting random seed to: {0}".format(args.seed)
        numpy.random.seed(args.seed)
    from toupee import data
    from toupee import config 
    from toupee.mlp import sequential_model

    params = config.load_parameters(args.params_file)

    def arg_params(arg_value,param):
        if arg_value is not None:
            params.__dict__[param] = arg_value

    for arg, param in arg_param_pairings:
        arg_params(arg,param)
    dataset = data.load_data(params.dataset,
                             pickled = params.pickled,
                             one_hot_y = params.one_hot)
    method = params.method
    method.prepare(params,dataset)
    train_set = method.resampler.get_train()
    valid_set = method.resampler.get_valid()
    members = []
    intermediate_scores = []
    final_score = None
    for i in range(0,params.ensemble_size):
        print 'training member {0}'.format(i)
        members.append(method.create_member())
        ensemble = method.create_aggregator(params,members,train_set,valid_set)
        test_set_x, test_set_y = method.resampler.get_test()
        test_score = accuracy(ensemble,test_set_x,test_set_y)
        print 'Intermediate test accuracy: {0} %'.format(test_score * 100.)
Exemplo n.º 7
0
#!/usr/bin/python
import sys
import numpy as np
import os
from toupee import data

if __name__ == '__main__':
    location = sys.argv[1]
    dest = sys.argv[1] + "_th/"
    if not os.path.exists(dest):
        os.mkdir(dest)
    shape = [int(x) for x in sys.argv[2].split(',')]
    dataset = data.load_data(location, pickled=False, one_hot_y=True)
    print dataset[0][0].shape
    np.savez_compressed(dest + 'train',
                        x=dataset[0][0].reshape([dataset[0][0].shape[0]] +
                                                shape),
                        y=dataset[0][1])
    np.savez_compressed(dest + 'valid',
                        x=dataset[1][0].reshape([dataset[1][0].shape[0]] +
                                                shape),
                        y=dataset[1][1])
    np.savez_compressed(dest + 'test',
                        x=dataset[2][0].reshape([dataset[2][0].shape[0]] +
                                                shape),
                        y=dataset[2][1])
Exemplo n.º 8
0
#!/usr/bin/python
import sys
import numpy as np
import os
from toupee import data

if __name__ == '__main__':
    location = sys.argv[1]
    dest = sys.argv[1] + "_th/"
    if not os.path.exists(dest):
        os.mkdir(dest)
    shape = [int(x) for x in sys.argv[2].split(',')]
    dataset = data.load_data(location,
                             pickled = False,
                             one_hot_y = True)
    print dataset[0][0].shape
    np.savez_compressed(dest + 'train',
            x=dataset[0][0].reshape([dataset[0][0].shape[0]] + shape),
            y=dataset[0][1])
    np.savez_compressed(dest + 'valid',
            x=dataset[1][0].reshape([dataset[1][0].shape[0]] + shape),
            y=dataset[1][1])
    np.savez_compressed(dest + 'test',
            x=dataset[2][0].reshape([dataset[2][0].shape[0]] + shape),
            y=dataset[2][1])
Exemplo n.º 9
0
    arg_param_pairings = [
        (args.seed, 'random_seed'),
        (args.results_db, 'results_db'),
        (args.results_host, 'results_host'),
        (args.results_table, 'results_table'),
        (args.epochs, 'n_epochs'),
    ]
    from toupee import config
    params = config.load_parameters(args.params_file)

    def arg_params(arg_value,param):
        if arg_value is not None:
            params.__dict__[param] = arg_value

    for arg, param in arg_param_pairings:
        arg_params(arg,param)

    from toupee import data
    from toupee.mlp import MLP, test_mlp
    dataset = data.load_data(params.dataset,
                             resize_to = params.resize_data_to,
                             shared = False,
                             pickled = params.pickled,
                             center_and_normalise = params.center_and_normalise,
                             join_train_and_valid = params.join_train_and_valid)
    pretraining_set = data.make_pretraining_set(dataset,params.pretraining)
    mlp = test_mlp(dataset, params, pretraining_set = pretraining_set)
    if args.save_file is not None:
        dill.dump(mlp,open(args.save_file,"wb"))
Exemplo n.º 10
0
    arg_param_pairings = [
        (args.results_db, 'results_db'),
        (args.results_host, 'results_host'),
        (args.results_table, 'results_table'),
        (args.epochs, 'n_epochs'),
    ]

    if 'seed' in args.__dict__:
        print "setting random seed to: {0}".format(args.seed)
        numpy.random.seed(args.seed)
    from toupee import data
    from toupee import config
    from toupee.mlp import sequential_model

    import toupee
    print "using toupee version {0}".format(toupee.version)
    params = config.load_parameters(args.params_file)

    def arg_params(arg_value, param):
        if arg_value is not None:
            params.__dict__[param] = arg_value

    for arg, param in arg_param_pairings:
        arg_params(arg, param)
    dataset = data.load_data(params.dataset,
                             pickled=params.pickled,
                             one_hot_y=params.one_hot,
                             join_train_and_valid=params.join_train_and_valid)
    mlp = sequential_model(dataset, params)
Exemplo n.º 11
0
#!/usr/bin/python

from toupee import data
import numpy as np
import argparse

if __name__ == '__main__':

    parser = argparse.ArgumentParser(description='Convert a pylearn2 dataset')
    parser.add_argument('--dest', help='the destination for the dataset')
    parser.add_argument('--source', help='the source of the data')
    parser.add_argument('--shape', help='new shape to enforce')
    parser.add_argument('--tf-to-th',
                        help='reorder dimensions from tf to th',
                        action='store_true')
    parser.add_argument('--th-to-tf',
                        help='reorder dimensions from th to tf',
                        action='store_true')
    args = parser.parse_args()

    dataset = data.load_data(args.source,
                             pickled=False,
                             one_hot_y=False,
                             center_and_normalise=True,
                             join_train_and_valid=False,
                             zca_whitening=True)

    np.savez_compressed(args.dest + "/train", x=dataset[0][0], y=dataset[0][1])
    np.savez_compressed(args.dest + "/valid", x=dataset[1][0], y=dataset[1][1])
    np.savez_compressed(args.dest + "/test", x=dataset[2][0], y=dataset[2][1])
Exemplo n.º 12
0
from toupee import data
import sys
import cPickle
import gzip
import os
import copy
import math
import numpy as np

if __name__ == '__main__':
    if len(sys.argv) > 2:
        dataset = sys.argv[1]
        fileName = sys.argv[2]
    else:
        raise Exception("need source and destination")
    dataset = data.load_data(dataset,pickled=False,shared=False)
    train,valid,test = dataset
    train_x, train_y = train
    valid_x, valid_y = valid
    test_x, test_y = test
#    n_in = test_x.shape[1]
#    params = { 'alpha': 0.0,
#               'beta': 30.0,
#               'gamma': 20.0,
#               'sigma': 1,
#               'pflip': 0.0,
#               'translation': 3.0,
#               'bilinear': True 
#             }
#    t = data.GPUTransformer(sharedX(train_x),
#                    x=int(math.sqrt(n_in)),