% function learner()

	more off;

	load('octave/X.txt');

    y = X(:,1);
    X = X(:,2:end);

    classes = max(y);

    Y = zeros(length(y), classes);
    for i = 1:length(y),
        Y(i, y(i)) = 1;
    end

	hidden = size(X, 2);

	arch = [hidden hidden classes];

	fprintf(stderr, 'Architecture:');
	fdisp(stderr, arch);

	if exist('octave/thetas.dat', 'file') == 2,
		load 'octave/thetas.dat';
		nlayers = uThetas(1);
		uThetas = uThetas(nlayers+2:end);
		if checkSize(arch) == length(uThetas),
			fprintf(stderr, 'continuing from previously computed theta values.\n');
			Thetas = roll(uThetas, arch);
		end
	end

	if not(exist('Thetas', 'var')),
		fprintf(stderr, 'initializing new theta values.\n');
	    Thetas = initializeThetas(arch);
	end

	opcoes = optimset('GradObj', 'on', 'MaxIter', __ITERACOES__);
	f = @(t) fminFunc(arch, X, Y, t);

	[ uThetas, C, erro] = fmincg( f, unroll(Thetas), opcoes);

    uThetas = [ length(arch) ; arch' ; uThetas ];

	save 'octave/thetas.dat' uThetas;

% end
