Optimization loop for number of neurons in neural network

4 ビュー (過去 30 日間)
Valeria
Valeria 2017 年 1 月 19 日
編集済み: Valeria 2017 年 1 月 19 日
Dear all,
I am trying to optimize the number of neurons in one-layer network in a simple "for"-loop. However, when I find the optimal number and try to establish the network again, I get a completely different result: the error is different. Knowing that the randomness is present, I try to fix the weights' assignment but it does not help.
I am definitely not an expert in ANN therefore probably can't simply understand where the problem comes from.
Here is my code
load data % loads X and Y tables
setdemorandstream(391418381)
SRmax = 0;
numNeuronsopt=0;
for i=1:20
numNeurons = 9+i;
net = patternnet(numNeurons);
[net,tr] = train(net,X,Y);
nntraintool
Xtest = X(:,tr.testInd);
Ytest = Y(:,tr.testInd);
Ytesthat = net(Xtest);
[MCR,ConfMat] = confusion(Ytest,Ytesthat);
fprintf('Percentage Correct Classification : %f%%\n', 100*(1-MCR));
fprintf('Percentage Incorrect Classification : %f%%\n', 100*MCR);
SR_temp = (1-MCR)*100;
if SR_temp>SRmax
SRmax = SR_temp;
numNeuronsopt = numNeurons;
end
end
Thank you for your help!

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by