Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
NARX learning

Subject: NARX learning

From: Mehdi

Date: 2 Jan, 2013 04:14:09

Message: 1 of 3

How to train NARX successfully?

Subject: NARX learning

From: Mehdi

Date: 2 Jan, 2013 04:52:08

Message: 2 of 3

"Mehdi " <mehdi_bg_53@yahoo.com> wrote in message <kc0c6h$l2e$1@newscl01ah.mathworks.com>...
> How to train NARX successfully?

I trained NARX opened form successfully, Then closed it and exert the same training data to see the the Responses. The Responses are awful and bad. I dont know why?(Because I trained opened loop with enough datasets e.g 100000 and mse=10e-7)
To solve the problem I try to train closed loop using lm. But because of large training data the training speed was very very low.I decreased data up to 1000 pairs. The training starts but after some iteration it stoped with the Maximum Mu Reached. I tested the resulted network with same data set that I have used for training. But the responses was awful again.
Any comment will be so helpfull.
my code
clc;
load outputs.mat
load inputs.mat
inputDelays = 0:2;
feedbackDelays = 1:2;
hiddenLayerSize = 27;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.inputs{2}.processFcns = {'removeconstantrows','mapminmax'};
net.trainFcn = 'trainlm'; % Levenberg-Marquardt
net.trainParam.min_grad=1e-10;
net.trainParam.max_fail=11;
net.trainParam.show=1;
net.trainParam.epochs = 100;
net.trainParam.goal = 1e-3;
net.trainParam.mu_max = 1e10;
%net.efficiency.memoryReduction = 2;
InputSeries= tonndata(inputs0,false,false);
OutputSeries= tonndata(outputs0,false,false);
[Inputs,inputStates,layerStates,targets] = preparets(net,InputSeries,{},OutputSeries);
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'value'; % Divide up every value
net.divideParam.trainRatio = 90/100;
net.divideParam.valRatio = 10/100;
%net.divideParam.testRatio = 15/100;
net.plotFcns = {'plotperform','plottrainstate','plotresponse', ...
  'ploterrcorr', 'plotinerrcorr'};
[net,tr] = train(net,Inputs,targets,inputStates,layerStates);
view(net)
% Closed Loop Network
%netc = closeloop(net);
%inputSeries= tonndata(inputs,false,false);
%targetSeries= tonndata(outputs,false,false);
%netC=netc;
%netC.name = [net.name ' - Closed Loop'];
%view(netC)
%[inputsC,inputStatesC,layerStatesC,targetsC] = preparets(netC,inputSeries,{},targetSeries);
%yC = netC(inputsC,inputStatesC,layerStatesC);
%closedLoopPerformance = perform(netC,targetsC,yC);
%netC.trainFcn = 'trainlm'; % Levenberg-Marquardt
%netC.trainParam.min_grad=1e-10;
%netC.trainParam.max_fail=21;
%netC.trainParam.show=1;
%netC.trainParam.epochs = 10000;
%netC.trainParam.goal = 1e-7;
%netC.trainParam.mu_max = 1e10;
%net.trainParam.mem_reduc = 1;
%[netC,trC] = train(netC,inputsC,targetsC,inputStatesC,layerStatesC);
%gensim(netC)

I have tested many ways(e.g running up to 1000 times, different numbers of hidden units and delays but no success yet)
give me your email to send inputs and outputs.
my email:mehdi.bgh@gmail.com
Mehdi,

Subject: NARX learning

From: Greg Heath

Date: 30 Mar, 2013 05:05:05

Message: 3 of 3

"Mehdi " <mehdi_bg_53@yahoo.com> wrote in message <kc0edo$s3p$1@newscl01ah.mathworks.com>...
> "Mehdi " <mehdi_bg_53@yahoo.com> wrote in message <kc0c6h$l2e$1@newscl01ah.mathworks.com>...
> > How to train NARX successfully?
>
> I trained NARX opened form successfully, Then closed it and exert the same training data to see the the Responses. The Responses are awful and bad. I dont know why?(Because I trained opened loop with enough datasets e.g 100000 and mse=10e-7)
> To solve the problem I try to train closed loop using lm. But because of large training data the training speed was very very low.I decreased data up to 1000 pairs. The training starts but after some iteration it stoped with the Maximum Mu Reached. I tested the resulted network with same data set that I have used for training. But the responses was awful again.
> Any comment will be so helpfull.

1. Are you sure the data is stationary?

2. Do not randomize the data division.

Hope this helps.

Greg

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us