Ejemplo n.º 1
0
TRAIN_STEPS = 500
BATCH_SIZE = 50


MNIST = False
# For MINST
if MNIST:
	import input_data_minst
	mnist = input_data_minst.read_data_sets('MNIST_data', one_hot=True)
	train_images, train_labels = mnist.train.images, mnist.train.labels
	test_images, test_labels = mnist.test.images, mnist.test.labels
else:
	print "Loading data"

	train_images, train_labels = input_data.load_train_data()
	test_images, test_labels = input_data.load_test_data()

FLAT_IMG_SIZE = train_images[0].shape[0]
NUM_CLASSES = train_labels.shape[1]
print "Data loaded"


import numpy as np
import tensorflow as tf

def init_weights(shape):
	return tf.Variable(tf.random_normal(shape, stddev=0.01))


def model(X, w, w2, w3, w4, w_o, p_keep_conv, p_keep_hidden):
	l1a = tf.nn.relu(tf.nn.conv2d(X, w, [1, 1, 1, 1], 'SAME'))
Ejemplo n.º 2
0
from __future__ import print_function

import os
import re
import sys
import tarfile

from six.moves import urllib
import tensorflow as tf
import numpy as np
import input_data

tf.set_random_seed(777)  # reproducibility
NUM_CLASSES = 10
train_x, _, train_y = input_data.load_training_data()
test_x, _, test_y = input_data.load_test_data()
# hyper parameters
learning_rate = 0.0001
training_epochs = 10
batch_size = 100

TOWER_NAME = 'tower'


def next_batch(i, batch_size):
    batch_num = int(100 / batch_size)
    if (i > batch_num - 1):
        while (i > batch_num):
            i -= batch_num
        if (i < 0):
            i = 0
Ejemplo n.º 3
0
	# Need to extend labels to match extra images
	labels_extended = []
	for theta in [20,45,90]:
		for freq in [.8]:
			print("Running Gabor",theta,freq)
			imgs.extend( map(lambda x: apply_filter(x,freq,theta), image_paths) )
			labels_extended.extend( labels )
	
	return imgs,labels_extended




#Loading data from input_data script
train_images,train_labels = input_data.load_train_data(apply_filters)
test_images,test_labels = input_data.load_test_data(apply_filters)



#Train SVM
classifier = svm.SVC(C=.01)
classifier.fit(train_images, train_labels)

train_score = classifier.score(train_images, train_labels)
train_xval_score = cross_validation.cross_val_score(classifier,train_images,train_labels,cv=10,scoring='accuracy')
test_score = classifier.score(test_images, test_labels)

print("Short Gabors 20-45-90,.8")
print("Train score:",train_score)
print("Train xval score:",train_xval_score)
print("Test score",test_score)
Ejemplo n.º 4
0
import tensorflow as tf
import numpy as np
import input_data

tf.set_random_seed(777)  # reproducibility
is_convert = False
train_x, _, train_y = input_data.load_training_data(is_convert)
test_x, _, test_y = input_data.load_test_data(is_convert)
is_convert = True
train_convert_x, _, train_convert_y = input_data.load_training_data(is_convert)
# hyper parameters
learning_rate = 0.001
training_epochs = 15
batch_size = 100


def next_batch(i, batch_size):
    batch_num = int(50000 / batch_size)
    if (i > batch_num - 1):
        while (i > batch_num):
            i -= batch_num
        if (i < 0):
            i = 0
    batch_x = train_x[i * batch_size:(i + 1) * batch_size]
    batch_y = train_y[i * batch_size:(i + 1) * batch_size]
    return batch_x, batch_y


def next_converted_batch(i, batch_size):
    batch_num = int(50000 / batch_size)
    if (i > batch_num - 1):