Exemple #1
0
	return (inputTrain, outputTrain, inputTest, outputTest)

def run(dataset, arhitecture, learning_rate, eval_every, stop):
	input_size = dataset["train_imgs"][0].shape
	nn = FeedForward(input_size, arhitecture)
	print(nn.to_string())

	return train_nn(nn, dataset, learning_rate, eval_every, stop)


if __name__ == "__main__":
	parser = ArgumentParser()
	parser.add_argument("--learning_rate", type = float, default = 0.001,
						help="Learning rate")
	parser.add_argument("--eval_every", type = int, default = 2000,
						help="Learning rate")
	args = parser.parse_args()
	
	#dataset = load_mnist()
	dataset = load_cifrar()

	input_size = dataset["train_imgs"][0].shape

	nn = FeedForward(input_size, [(CONV, (6, 28, 28), 5, 1), (RELU, -1), (MAX_POOLING, (6, 14, 14)), (CONV, (16, 10, 10), 5, 1), (RELU, -1), (MAX_POOLING, (16, 5, 5)), 
		(LINEARIZE, -1), (FULLY_CONNECTED, 120), (FULLY_CONNECTED, 84), (FULLY_CONNECTED, 10) ,(SOFTMAX, -1)])
	#nn = FeedForward(input_size, [(LINEARIZE, -1), (FULLY_CONNECTED, 300), (TANH, -1), (FULLY_CONNECTED, 100), (TANH, -1), (FULLY_CONNECTED, 10), (SOFTMAX, -1)])
	print(nn.to_string())

	train_nn(nn, dataset, args.learning_rate, args.eval_every, 10000)
#!/usr/bin/python

from pylab import plot, show, arange, legend, xlabel, ylabel
from train import run
from data_loader_mnist import load_mnist
from data_loader_cifrar import load_cifrar
from feed_forward import LINEARIZE, FULLY_CONNECTED, TANH, SOFTMAX

xlabel('Numarul de imagini de antrenare')
ylabel('Acuratete')

mnist = load_mnist()
cifrar = load_cifrar()
arhitecture = [(LINEARIZE, -1), (FULLY_CONNECTED, 300), (TANH, -1), (FULLY_CONNECTED, 100), (TANH, -1), (FULLY_CONNECTED, 10), (SOFTMAX, -1)]
(inputTrainC, outputTrainC, inputTestC, outputTestC) = run(cifrar, arhitecture, 0.002, 4000, 40000)

x = inputTrainC
y = outputTrainC
plot(x, y, color='green', label='CIFAR_TRAIN')

x = inputTestC
y = outputTestC
plot(x, y, color='blue', label='CIFAR_TEST')

legend(prop={'size':6})
show()