function [nets,errs,erts]=run(x, y, xt, yt)
%RUN	Train a set of neural networks.
%
%	[nets,errs,code] = RUN (x, y);
%
%	See also: NEWNET, INITNET, TRAINNET.

%	Ling Li, Caltech
%	10/21/96, 10/09/00

if size(x, 1) ~= size(y, 1)
	error('input x and y do not agree');
end

nns = 8;
lrs = [0.05];
wrs = [0.2];
etas = [0.001, 0.01, 0.1];
betas = [0.1, 0.5, 1, 2];

%etas = [0.01];
%betas = [0.5];

maxnum = length(nns) * length(lrs) * length(wrs) * length(betas)^2;

tests = 3;
epochs = 2000;
minerr = 4e-4;
delta = 0.1;
nets = cell(maxnum, tests);
errs = cell(maxnum, tests);
erts = cell(maxnum, tests);

beta = cell(1, 2);
for test = 1:tests, num = 0; for n = nns, for wr = wrs, 
	net = initnet(newnet([2, n, 1]), [-wr, wr]);
	for lr = lrs, for eta = etas, for b1 = betas, for b2 = betas, 
		num = num + 1;
		beta{1} = b1; beta{2} = b2;
		disp(['test ' num2str(test) ' for lr = ' num2str(lr) ', eta = ' num2str(eta)]);
		[nets{num,test}, errs{num,test}, erts{num,test}] = ...
			traintst(net, x, y, xt, yt, [lr, epochs, eta, minerr, delta], beta, 'seq');
		pause(0);
	end, end, end, end
end, end, end
