Optimization loop for number of neurons in neural network
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Define Shallow Neural Network Architectures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!