ALWAYS SAME RESULT WITH NEURAL NETWORK SCRIPT

Hello,
I'm testing some examples of work with neural networks but I have found and issue and maybe someone could help with it.
In fact, I have been trying nprtool with the test database "Breast Cancer" in Matlab R2014a. When I train the network with nprtool I have different results everytime, but when I export the Neural Network to a script (simple or advanced) I have always exactly the same result.
% Solve a Pattern Recognition Problem with a Neural Network
% Script generated by Neural Pattern Recognition app
% Created Wed Oct 26 18:09:48 CEST 2016
%
% This script assumes these variables are defined:
%
% cancerInputs - input data.
% cancerTargets - target data.
x = cancerInputs;
t = cancerTargets;
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
performance = perform(net,t,y)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, plotconfusion(t,y)
%figure, plotroc(t,y)
%figure, ploterrhist(e)
I have watching the values and the problem it's that the variables "tr.trainInd", "tr.valInd", "tr.testInd" take always the same values, even chosing the option dividerand. But if I make some test into the comand line, using the command:
[XtrainInd,XvalInd,XtestInd] = dividerand(400,0.4,0.3,0.3)
I have different values every time. The idea is to train the network many times, taking a different test sample each time to verify that the neural network is running well, but I can't find how to do it.
Thanks in advance to everyone for your help.

댓글 수: 1

Iker Martin
Iker Martin 2016년 10월 27일
After doing a lot of tests, I have tried to install version 2016a instead of 2014a and finally the code takes different values everytime, so maybe it's a problem with the version I was using.

댓글을 달려면 로그인하십시오.

답변 (1개)

Greg Heath
Greg Heath 2016년 10월 29일

1 개 추천

The only way for this to happen with 2014a is for the RNG to be initialized to the same state at the beginning.
Hope this helps.
Thank you for formerly accepting my answer
Greg

질문:

2016년 10월 26일

답변:

2016년 10월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by