MATLAB: How to estimate the error of a Neural Network training session using BOOTSTRP function

bootstrapDeep Learning Toolbox

I want to know how I can use the BOOTSTRP function from the Statistics Toolbox to estimate the error of a neural network training session
with a training set, a validation set, and a test set.

Best Answer

The following is a simple example that demonstrates the use of the BOOTSTRP function to estimate the error.
function estimateError
X = [0:0.1:4]';
Y = sin(X)';
net = newff(minmax(X'),[21 1],{'tansig' 'purelin'}); % Create a neural network
net.trainParam.show = NaN; % don’t show learning curve plot
stats = bootstrp(10, @(X,Y) bootstrptst(X,Y,net), X,Y) % bootstrap
plot(stats) % plots how the network error responded to 10 training sessions using
% 41 samples resampled randomly from x and y variables
%%%%%%%%%%%%%%%%%%
% bootstrptst.m
%%%%%%%%%%%%%%%%%
function err = bootstrptst(p, t, mynet)
p = p'; % assuming samples are rows and input attributes are columns
t = t'; % assuming samples are rows and output attributes are columns
[mynet, TR, out] = train(mynet, p, t); %train
err = mse(out-t); % return error