How to train a neural network to 0.1 error rate?

3 views (last 30 days)
Hello,
I have written this code to train a neural network with 500 samples as the inputs and 32 attributes.Its a classification problem and i have two classes in the target.
net=fitnet(30,'trainlm');
net.divideParam.trainRatio=.7;
net.divideParam.valRatio=.15;
net.divideParam.testRatio=.15;
[net,tr] = train(net,input500',target500');
Output=net(sample')';
the code is working although the output of the sample isn't perfect yet. I need explanation on how i can calculate error rate after each epoch. Also i want the neural network to continue its training until the error rate is less than 0.1 Please how can i achieve this. Thanks in anticipation.

Accepted Answer

Greg Heath
Greg Heath on 17 Jan 2016
1. Error rate cannot be used as a training function because it is discontinuous.
2. PATTERNNET, the current default classification/pattern-recognition function, is more appropriate than FITNET which is designed for regression/curve-fitting. See the documentation
help patternnet
doc patternnet
2. For examples, search BOTH the NEWSGROUP and ANSWERS using
greg patternnet
3. For c classes, the c x N target matrix is obtained from the true class indices 1:c via IND2VEC. The estimated class indices are obtained from the output via VEC2IND. Class error rates are obtained by comparing true and estimated indices.
4. Since it is impossible to directly design for a given error rate, the best approach is, for a given number of hidden nodes, H, make multiple (e.g., Ntrials = 10) designs using different random initial weights.
5. To get a feel for it, start with default value H = 10. Then, use a for loop over H = Hmin:dH:Hmax to try to obtain the smallest value of H that will yield acceptable results. You will have to design at least
Ndesigns = Ntrials*numel(Hmin:dH:Hmax)
6. See previous posts and write back if you need help.
Hope this helps,
Thank you for formally accepting my answer
Greg
  2 Comments
Omotayo Asiru
Omotayo Asiru on 18 Jan 2016
Thanks so much for your response.Now i have this code : net = patternnet(30); net = train(net,x,t); view(net); y = net(x); perf = perform(net,t,y); classes = vec2ind(y); where x and t are the input and target respectively. Is this good enough to train the network or how can i improve on it? I do not understand how to implement your point 4 and 5 above in my code. And again,please how can i supply my input and target from a file to the neural network editor. I have tried all the load functions but it keeps giving error. I had to supply just 20 samples in the editor to test the code above and i will not be able to do that with a large data set.
Greg Heath
Greg Heath on 24 Jan 2016
You haven't looked up any of my patternnet posts in either the NEWSGROUP or ANSWERS!!!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!