ALWAYS SAME RESULT WITH NEURAL NETWORK SCRIPT
Mostra commenti meno recenti
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 Commento
Iker Martin
il 27 Ott 2016
Risposte (1)
Greg Heath
il 29 Ott 2016
1 voto
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
Categorie
Scopri di più su Pattern Recognition in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!