function [net, acc, time] = trainnns(DATA, LABELS, NHID, NIT, ALPHA)
% [net, acc, time] = traingmms(DATA, LABELS, NHID)
% Train two Gaussian mixture models and evaluate their accuracy
% on the training data. DATA is rows of training feature vectors,
% with corresponding 0/1 labels in LABELS. Train a pair of GMMs
% with NGAUSS components, return in M1 (for label 0) and M2 (for
% label 1). Report the % correct on the training data and return
% it in acc. Return total elapsed time in time.
% 2003-06-30 dpwe@ee.columbia.edu muscontent practical
% Start execution timer
tic;
if nargin < 3
NHID = 5;
end
if nargin < 4
NIT = 10;
end
if nargin < 5
ALPHA = 0.2;
end
ndim = size(DATA, 2);
options = zeros(1,18);
options(9) = 1; % Check the gradient calculations
options(14) = NIT;
nout = 1;
net = mlp(ndim, NHID, nout, 'logistic', ALPHA);
net = netopt(net, options, DATA, LABELS, 'quasinew');
% Evaluate net output over all training frames
out = mlpfwd(net, DATA);
% Overall classification accuracy on training data
acc = mean( (out>0.5) == LABELS);
disp(['Accuracy on training data = ',num2str(round(1000*acc)/10), '%']);
% How long did it take?
time = toc;
disp(['Elapsed time = ', num2str(time),' secs']);