% adopted from DeepLearnToolbox. Added p value to the output.
function [labels,p] = nnpredict(nn, x)
    nn.testing = 1;
    nn = nnff(nn, x, zeros(size(x,1), nn.size(end)));
    nn.testing = 0;
    p=nn.a{end};
    [dummy, i] = max(p,[],2);
    labels = i;
end
