How to improve the performance of my neural network
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am using matlab nprtool to train a neural network for classification. I have 367 data samples of 32 inputs and 2 classes. 207 belongs to class A and the remaining 160 belongs to the other class.I have changed the number of hidden layer many times but the one that produced a manageable result is 15. However the result is not satisfactory enough. 55 test sample was given to the trained net, 34 were classified correctly and 21 wrongly. I have a normalized dataset but i did not use it because i saw online that nprtool does normalization to all dataset by default. Please,how can i increase the performance of the network. Also, i changed training function from trainscg to trainlm but that has not helped. Below is the code generated by matlab.
%Input367_Decimal - input data.
target367 - target data.
inputs = Input367_Decimal;
targets = target367;
% Create a Pattern Recognition Network
hiddenLayerSize = 15;
net = patternnet(hiddenLayerSize);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% For help on training function 'trainlm' type: help trainlm
% For a list of all training functions type: help nntrain
net.trainFcn = 'trainlm'; % Levenberg-Marquardt
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = 'mse'; % Mean squared error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotregression', 'plotfit'};
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
% Recalculate Training, Validation and Test Performance
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
figure, plotconfusion(targets,outputs)
%figure, ploterrhist(errors)
Any help will be much appreciated. Thanks
5 Kommentare
Greg Heath
am 19 Sep. 2016
Your initial post says number of number of hidden layers where you should have said number of hidden layer NODES.
HTH
Greg
Antworten (1)
Greg Heath
am 19 Sep. 2016
The code you posted is too complicated for your first time out. See the examples in the documentation using the commands
help patternnet
doc patternnet
Then try the example data in
help nndatasets
doc nndatasets
Finally, you can search BOTH the NEWSGROUP and ANSWERS using
greg patternnet.
Hope this helps.
Thank you for formally accepting my answer
Greg
Siehe auch
Kategorien
Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!