how to decrease fluctuation in neural network results?

  • Permalink
  • submit to reddit
  • Email
  • Follow


when i run my ANN code it gives me result ...some times very good and sometimes very bad. so how to decrease fluctuations in the result and and some times performance curve show overfitting although with small data and on jst running the program once.
source code is given below:

This is my source code and I want to reduce the possible errors. When running this code there is a lot of difference between trained output to target. I have tried different ways but didn't work so please help me reducing it.

a=[31 9333 2000;31 9500 1500;31 9700 2300;31 9700 2320;31 9120 2230;31 9830 2420;31 9300 2900;31 9400 2500]'
g=[35000;23000;3443;2343;1244;9483;4638;4739]'
h=[31 9333 2000]'


inputs =(a);
targets =[g];

% Create a Fitting Network
hiddenLayerSize = 1;
net = fitnet(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','plotconfusion' 'plotfit','plotroc'};
% Train the Network
[net,tr] = train(net,inputs,targets);
plottrainstate(tr)

% Test the Network
outputs = net(inputs)
errors = gsubtract(targets,outputs)
fprintf('errors = %4.3f\t',errors);
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);
sc=sim(net,h 
0
Reply bilal_zafar9 (18) 10/14/2013 8:22:05 PM

See related articles to this posting

comp.soft-sys.matlab 203557 articles. 529 followers. Post

0 Replies
65 Views

Similar Articles

[PageSpeed] 26


Reply:

Similar Artilces:

how to get neural network result
If NN is trained with train(net,P,T). Let training of data has been done for images and generate matrices for P. T is the output assigned for respective P image matrices. Now, How to test the network with testing data? where testing data is matrix form of images. Do we need to run sim(net, test_matrix)? If yes, how to interpret output? ...

weird neural network results
Hello, Using the code in this tutorial (http://www.informit.com/content/index.asp?product_id=%7BEB1A220C-4401-40C1- 83D1-A15C073B6507%7D) , I built: a 2-neuron input layer a 2-neuron hidden layer a 1-neuron output layer I trained it the xor operator using 10,000 iterations for each input/output combinations. When I tested it, I usually get the right answers: 0.0 - 0.0 = 0.0038773712493636787 0.0 - 1.0 = 0.9960101571120731 1.0 - 0.0 = 0.9960088662028559 1.0 - 1.0 = 0.004875503827332909 Sometimes I get some unusual answers, such as these: 0.0 - 0.0 = 0.0037886942160241096 0.0 - 1.0 = 0.499...

Result vector of neural network
Hi, As far as I know, when a neural network (e.g. multilayer, backprop) is applied for classification, the output neuron with the highest excitation is chosen as result. What about taking the highest X excitations and try to classify? For example: 3 different classifications are performed. The four highest outputs of each classification run are displayed below (a-c) Output a = [ 1 3 4 5] --> 1 Output b = [ 1 7 16 9] Output c = [3 1 4 5] For some reason we know that Output a is correct. The question is if b and c return the correct result. If one looks at output b and c one would probabl...

Neural Network Result for Furture
Hi, everybody I have a basic problem about the Neural Network tools of Matlab. When I finished the train of network use net = newrb(P,T,0.02,1); How can I save this result and reuse this network for furture forecaseing(This network is create for forecasting somethings). So my questing is How do I save the resule? How do I reuse it in furture? Thanks a lot. Angler Chiang ...

Neural Network Poor Simulation Result
Hi I am using the nntool to predict target values. My Matlab version is R2008b. I divided my whole data into training set (70%) and testing set (30%) by the year. My training results are acceptable (Regression R= 0.8 or higher), but my simulation results (using testing set) are really bad (the correlation coefficient are close to zero or even negative). If that's because I divided the training and testing set by time? Is there any way to improve the SIM results? Like randomize the training and testing data? Thank you in advanced! ...

How to compare the results of neural networks and regression?
Hello, I want to compare my results of an MLP with traditional (linear) regression and I'm not quite sure how to do that correctly. Is r-square a good validator or not and on which sets should the models be "trained" and validated. Which other validation possiblities can/should be used (i.e. MSE)? Read a lot of articles on comparisons between those models now and most of them give very little insights into the exact method of comparison. I'd be glad if anybody had some literature tips for me or some other help. Thank you very much. Bastian ...

Help! Neural Network Poor Simulation Result
Hi I am using the nntool to learn and predict target values. My Matlab version is R2008b. I divided my whole data into training set (70%) and testing set (30%) by the year. My training results are acceptable (Regression R= 0.8 or higher), but my simulation results (using testing set) are really bad (the correlation coefficient are close to zero or even negative). If that's because I divided the training and testing set by time? Is there any way to improve the SIM results? Like randomize the training and testing data? Thank you in advanced! On Oct 27, 6:01=A0pm, asleo24 <asl...

classified results vs targets Neural network
Dear Friend, I am using NN for classification. I have defined two targets as: Class A [1 0] and Class B [0 1]. If the output is [1 0], I certainly know it belongs to class A. However, if the output is not perfect, say, [0.56 0.43], how do I know this belongs to which class? The 'plotconfusion' function in Matlab gives the statistics by knowing the outputs and targets. But how does it actually calculate those statistics ? Please give me a help! Thanks a lot! On Aug 25, 10:19 am, "Tao Sun" <t...@ecs.soton.ac.uk> wrote: > Dear Friend, > > I am using NN fo...

Neural Network Resources
Hi everyone, Thanks for voting. The result and a new poll are now available online. Please feel free to check them out and submit your vote. http://www.makhfi.com thanks in advance, -Pejman ...

Sectors using Neural Networks
Hi everyone, thanks for voting. The result is now available for your review. Frankly I was surprised to see no one voted for BioTech! Any thought on that? There is also a new poll available to capture market share of Neural Network tools. Please feel free to check it out and submit your vote. http://www.makhfi.com thanks in advance, -Pejman ...

Neural Network Tools
Hi everyone, Thanks for voting. The result and a new poll are now available online. Please feel free to check them out and submit your vote. http://www.makhfi.com thanks in advance, -Pejman ...

Favorite Neural Networks Tools
Hi everyone, Thanks for voting. The result and a new poll are now available online. Please feel free to check them out and submit your vote. http://www.makhfi.com thanks in advance, -Pejman ...

Neural Network Tools
Hi everyone, Thanks for voting. The result and a new poll are now available online. Please feel free to check them out and submit your vote. http://www.makhfi.com thanks in advance, -Pejman ...

Neural Networks Cant Generalize..Results error in New Data
Hi all of you. i got a problem in Neural Networks.my net doesnt produce required results when new data( test ) data is applied.it is 100% good in memorization..im not what is the problem, can any one help/suggest what is the actual problem...the code goes as below: clear;clc; % SET CHARACTERS: alphabet =Alpha4Train(); targets=TargetSet();%eye(23);% [Sa,Qa] = size(alphabet); [S2,Q] = size(targets); ValidatingChar=Alpha4Test(); TestMem=alphabet(:,77); TestGen1=ValidatingChar(:,1); TestGen2=ValidatingChar(:,2); TestGen3=ValidatingChar(:,3); % DEFINING THE NETWORK % ==================== S1 =...

neural network appcr1 character rec demo gives bad results?
I have run the appcr1 character recognition demo several times. The performance is terrible and nothing close to what the documentation says. My display results plot showing the percentage of errors show over 90% errors even for no noise level. What's wrong with this demo?? ...

help! try to contruct the simulation result of neural network by computing directly
Using nftool. I get the weights and bias by training the network. then I compute the result directly by: w2*tansig(w1*input+b1)+b2 where w1=weights in layer 1, w2=weight in layer 2, b1=bias 1, b2=bias 2 But the result is different from the output from simulation. Even I use the nntool to cinstruct the network myself , I still cannot get the right one...What's wrong?? Thanks a lot!! "leo " <leochengst@gmail.com> wrote in message <hlc6lb$iu8$1@fred.mathworks.com>... > Using nftool. I get the weights and bias by training the network. then I compute the result dir...

Neural Networks-- train function error Indexing cannot yield multiple results.
I've used the nprtool to generate the script to train a neural network. I wanted to change the training algorithm from trainlm to conjugate gradient descent or something like that. % Solve a Pattern Recognition Problem with a Neural Network % Script generated by NPRTOOL % Created Tue Nov 01 18:08:00 IST 2011 % % This script assumes these variables are defined: % % train - input data. % train_labels - target data. clc; inputs = train'; targets = train_labels'; % Create a Pattern Recognition Network hiddenLayerSize = 60; net = patternnet(hiddenLayerSize); ...

Is it possible to use 2 or more inputs to a Neural Network and implement the result in C-kode ?
I am quite new to the Neural Toolbox in Matlab, and have som difficulties. I am trying to feed a network 3 inputs and 1 target to identifiy a function. Anybody knows if this is possible with the toolbox in MatLab and if this can be implemented in C-kode and on a controller that only uses integer values ? I would be glad if anybody have a solution to this ! OAG <gjerpe1970@hotmail.com> wrote in message news:<eef3df0.-1@webx.raydaftYaTP>... > I am quite new to the Neural Toolbox in Matlab, and have som > difficulties. > > I am trying to feed a network 3 inputs and 1 ...

neural network appcr1 character rec demo gives bad results? #2
I have run the appcr1 character recognition demo several times. The performance is terrible and nothing close to what the documentation says. My display results plot showing the percentage of errors show over 90% errors even for no noise level. What's wrong with this demo?? ...

Neural Networks-- train function error Indexing cannot yield multiple results. #2
I've used the nprtool to generate the script to train a neural network. I wanted to change the training algorithm from trainlm to conjugate gradient descent or something like that. % Solve a Pattern Recognition Problem with a Neural Network % Script generated by NPRTOOL % Created Tue Nov 01 18:08:00 IST 2011 % % This script assumes these variables are defined: % % train - input data. % train_labels - target data. clc; inputs = train'; targets = train_labels'; % Create a Pattern Recognition Network hiddenLayerSize = 60; net = patternnet(hiddenLayerSize); ...

neural network: Recurrent Neural Networks
Hi Greg and Anders, thanks for your help of my backpropagation topic. Now I switch to recurrent neural networks. My question: 1. Does it the recurrent neural networks need to divide input data into training, validation and testing 3 sets? I tried to convert my previous brackpro code into recurrent but it prompt out the error that the "train" code section has too many input arguements, which include VV and TV... Felix Hi I tried to use Elam network. One strange result came to me. I used 10 hidden units it shown that the preformance goal is not met. and the mse is about 8.5 . Then ...

Neural Network Architecture with MATLAB Neural Network Toolbox
Dear neural network experts, I would like to make a neural network model for a situation when some of the input variables can interact, while others don't have any interactions. This information is based on logical considerations and I have to include it into the architecture of the net. For example, I have 3 different groups of input variables. Within each groups the variables are disjunct (i.e. no interaction). Variables of different groups may interact. This would result in either - restrictions to some weights of a network consisting of completely inter-linked neurons (i.e. some weight...

neural network predictiver controller in neural network toolbox
I got some question that would like to ask about the minimizaton routine in neural network predictive controller in neural network toolbox. 1. Is there any method to calculate the control signal which minimize the performance index beside using Simulink? Any Matlab command which is relevant for minimization of performance index? 2. What is the teory for minimization routine like csrchbac? Is there any reference that I can refer? I am looking forward for any reply from any other Matlab user. Thank you very much for spending your time to read my message. Thanks again. Hi, G.H.Heng you work ...

Probabilistic Neural Network and Radial basis function Neural Network
I am a final year student in B.Tech Information Technology. I am doing a project related to object recoginition using Probabilistic Neural Network and Radial basis function Neural Network. Please send me the running code of these networks. Thanx ...