Exemplo 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):
Exemplo n.º 2
0
	imgs = []
	# 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)