function [output, hidden] = mlpforward(inputs, w1, w2)
% calculates the output response for a multi-layer perceptron with parameters w1, and w2
% w1 is Nin+1 x Nhidden 
% w2 is Nhidden+1 x Nout
% can take matrix input and provide matrix output of output responses 
% and the hidden neurons' responses

[N,diminputs]  = size(inputs);

% calculate input activation (sum of product of weights with inputs)
hiddenactivation = [ones(N,1) inputs]*w1;

% calculate a sigmoid function of activation for hidden units
hidden = 1./(1+exp(-hiddenactivation));

% calculate activation of output units
outputactivation = [ones(N,1) hidden]*w2;

% calculate a sigmoid function of activation for hidden units
output = 1./(1+exp(-outputactivation));
