In the documentation we are training 10 different neural networks, each initialized with different weights and biases. net
is the variable for constructing the neural networks, x1
is the training dataset, t1
is the known labels used in training, x2
is the test dataset and t2
is the test label. Each neural network is stored in a cell variable NN{}
.
After training, the evaluation is done using the test set t2
and x2
, However, the mse calculation is done using mse(net, t2, y2)
I think the correct statement should have been mse(NN{i}, t2, y2)
since NN{}
is the trained model and not net
which is just a structure. Below is the code given in the link.
Should the function call be mse(NN{i}, t2, y2)
instead of mse(net, t2, y2)
?
net = feedforwardnet(10);
numNN = 10;
NN = cell(1, numNN);
perfs = zeros(1, numNN);
for i = 1:numNN
fprintf('Training %d/%d\n', i, numNN);
NN{i} = train(net, x1, t1);
y2 = NN{i}(x2);
perfs(i) = mse(net, t2, y2);
end
mse
is a network performance function. It measures the network’s performance according to the mean of squared errors.
perf = mse(net,t,y,ew)
takes these arguments:
net
Neural networkt
Matrix or cell array of targetsy
Matrix or cell array of outputsew
Error weights (optional)
As per the documentation of mse
. So the first parameter should be a structure of the neural network
type, with NN{i}
being contained in y2
in that example, thus the matrix of outputs.