from conv_net import build_network args = GetOptions() if args['activation'] == 'rectify': activation_function = rectify elif args['activation'] == 'leaky_rectify': activation_function = leaky_rectify elif args['activation'] == 'very_leaky_rectify': activation_function = very_leaky_rectify else: raise ValueError('Unknown activation function') args['activation_function'] = activation_function X, y, images_id = load_numpy_arrays(args['train_file']) sample_size = y.shape[0] - y.shape[0] % args['batch_size'] X = X[:sample_size] y = y[:sample_size] print "Train:" print "X.shape:", X.shape print "y.shape:", y.shape y_counts = np.unique(y, return_counts=True)[1] print "y value counts: ", y_counts print "pictures size: ", sqrt(X.shape[1]/3.) args['dataset_ratio'] = 3.8 args['network'] = 'AlexNet' args['batch_size'] = 141
__author__ = 'thiebaut' __date__ = '07/11/15' args = GetOptions() if args['activation'] == 'rectify': activation_function = rectify elif args['activation'] == 'leaky_rectify': activation_function = leaky_rectify elif args['activation'] == 'very_leaky_rectify': activation_function = very_leaky_rectify else: raise ValueError('Unknown activation function') args['activation_function'] = activation_function X, y, images_id = load_numpy_arrays(args['train_file']) sample_size = y.shape[0] - y.shape[0] % args['batch_size'] X = X[:sample_size] y = y[:sample_size] print "Train:" print "X.shape:", X.shape print "y.shape:", y.shape y_counts = np.unique(y, return_counts=True)[1] print "y value counts: ", y_counts print "pictures size: ", sqrt(X.shape[1]/3.) # Compute over-sampling of class 1 dataset_ratio = float(y_counts[1])/y_counts[0] print "Labels ratio: {:.2f}".format(dataset_ratio) if args['initial_ratio'] is None:
#!/usr/bin/env python # -*- coding: utf-8 -*- from utils import make_submission_file from utils import load_numpy_arrays from datetime import date import cPickle import sys conv_net = cPickle.load(open(str(sys.argv[1]),'rb')) # ----- Test set ---- X_test, _, images_id_test = load_numpy_arrays('test.npz') print "Test:" print "X_test.shape:", X_test.shape predictions = conv_net.predict_proba(X_test) make_submission_file(predictions, images_id_test, output_filepath='submissions/submission_'+str(date.today)+'.csv')