Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Neural network with multiple inputs and single output - How to improve the performance of neural network?

149 views
Skip to first unread message

pepper yuan

unread,
Apr 8, 2016, 1:44:11 AM4/8/16
to
Hello everyone! I would like to create a neural network with 5 input nodes. In the following I have created a simple code with the help of the neural network toolbox. I have a question regarding this code.

How can i improve the performance of network as i use different training algorithm (trainlm and trainscg) with different transfer function(logsig and tansig) in hidden layer, but the best results obtained are only 0.64 MSE and 0.35 R by using trainlm and tansig.

Here is my code:

x = rinputs;
t = rtargetfourthroot;
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = 15;
net = fitnet(hiddenLayerSize,trainFcn);
% Selection of internal transfer functions
net.layers{1}.transferFcn = 'tansig';
net.layers{2}.transferFcn = 'purelin';
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.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 = 60/100;
net.divideParam.valRatio = 20/100;
net.divideParam.testRatio = 20/100;
% 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,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
Thank you

Greg Heath

unread,
Apr 8, 2016, 2:36:08 AM4/8/16
to
"pepper yuan" wrote in message <ne7gf3$pn6$1...@newscl01ah.mathworks.com>...
> Hello everyone! I would like to create a neural network with 5 input nodes. In the following I have created a simple code with the help of the neural network toolbox. I have a question regarding this code.
>
> How can i improve the performance of network as i use different training algorithm (trainlm and trainscg) with different transfer function(logsig and tansig) in hidden layer, but the best results obtained are only 0.64 MSE and 0.35 R by using trainlm and tansig.

I have found the parameter choices in the help and doc documentation example

help fitnet

and

doc fitnet

sufficient for the hundreds of examples I have posted (search BOTH the NEWSGROUP and ANSWERS using the search words GREG FITNET)..

Typically, as illustrated in most of these examples, the MOST IMPORTANT choice is to vary the number of hidden nodes and the initial random weights.

> Here is my code:

Unfortunately, unlike my examples, it is not based on the codes in the help and doc documentation examples. To narrow down the searches add the term
tutorial
NEWSGROUP ANSWERS
greg fitnet tutorial 15 25

Hope this helps.

Greg
0 new messages