def load_data(): svhn = SVHN() X_train, y_train = svhn.load_preprocessed_data('train') X_test, y_test = svhn.load_preprocessed_data('test') # svhn.visualize(X_train, y_train) return X_train, y_train, X_test, y_test
momentum = 0.9 weightdecay = 0.01 finetune_lr = 1e-2 finetune_epc = 400 print " " print "batchsize =", batchsize print "momentum =", momentum print "finetune: lr = %f, epc = %d" % (finetune_lr, finetune_epc) ############# # LOAD DATA # ############# svhn_data = SVHN() train_x, train_y = svhn_data.get_train_set(include_extra=False) test_x, test_y = svhn_data.get_test_set() train_smp = train_x.shape[0] test_smp = test_x.shape[0] print "\n... pre-processing" preprocess_model = SubtractMeanAndNormalizeH(train_x.shape[1]) map_fun = theano.function([preprocess_model.varin], preprocess_model.output()) train_x = map_fun(train_x.astype(theano.config.floatX)).reshape((train_smp, 32, 32, 3)).swapaxes(1, 3) test_x = map_fun(test_x.astype(theano.config.floatX)).reshape((test_smp, 32, 32, 3)).swapaxes(1, 3) train_x = theano.shared(value=train_x, name='train_x', borrow=True) train_y = theano.shared(value=train_y.astype('int64') - 1, name='train_y', borrow=True) test_x = theano.shared(value=test_x, name='test_x', borrow=True) test_y = theano.shared(value=test_y.astype('int64') - 1, name='test_y', borrow=True)
weightdecay = 0.01 finetune_lr = 1e-4 finetune_epc = 400 part_size = 100000 print " " print "batchsize =", batchsize print "momentum =", momentum print "finetune: lr = %f, epc = %d" % (finetune_lr, finetune_epc) ############# # LOAD DATA # ############# svhn_data = SVHN() train_x_np, train_y_np = svhn_data.get_train_set(include_extra=True) test_x, test_y = svhn_data.get_test_set() train_smp = train_x_np.shape[0] test_smp = test_x.shape[0] print "\n... pre-processing" preprocess_model = SubtractMeanAndNormalizeH(train_x_np.shape[1]) map_fun = theano.function([preprocess_model.varin], preprocess_model.output()) train_x_accu = [] for i in range(train_smp/part_size): train_x_accu.append(map_fun( train_x_np[i * part_size : (i + 1) * part_size].astype(theano.config.floatX) ).reshape((part_size, 32, 32, 3)).swapaxes(1, 3)) train_x_accu.append(map_fun(