How to use a trained narx network with only input variable ?

%?How to use a trained narx network with only input variable
% Asked by Leon on 17 Aug 2012 at 7:14
> I am using the NARX function of Neural Network Toolbox. In the User's
> Guide, Neural Network Toolbox, R2012a. Page 3-23, there is an example as
> below. (u is the input and y is the output).
> load magdata
> [u,us] = mapminmax(u);
> [y,ys] = mapminmax(y);
> y = con2seq(y);
> u = con2seq(u);
> d1 = [1:2];
> d2 = [1:2];
> narx_net = narxnet(d1,d2,10);
> narx_net.divideFcn = '';
> narx_net.trainParam.min_grad = 1e-10;
> [p,Pi,Ai,t] = preparets(narx_net,u,{},y);
Write the 4 explicit algebraic equations that yield the 4 outputs [p,Pi,Ai,t] in terms of the 2 open loop inputs u and y
> narx_net = train(narx_net,p,t,Pi); % Ai is empty
Note that open loop narx_net is explicitly defined by t
> yp = sim(narx_net,p,Pi);
> e = cell2mat(yp)-cell2mat(t);
> plot(e);
> narx_net_closed = closeloop(narx_net);
Note that closed loop narx_net is NOT explicitly defined by t
> y1=y(1700:2600);
> u1=u(1700:2600);
> [p1,Pi1,Ai1,t1] = preparets(narx_net_closed,u1,{},y1);
Write the 4 explicit algebraic equations that yield the 4 outputs [p1,Pi1,Ai1, t1] in terms of the 2 open loop inputs u1`and y1, In particular, concentrate on Ai1 and t1.
> yp1 = narx_net_closed(p1,Pi1,Ai1);
Note that yp1 is explicitly defined by t1 ONLY through the 2 initial feedback delay conditions stored in Ai1.
> plot([cell2mat(yp1)' cell2mat(t1)']);
> Now I would like to use this function to first train the network (so the > first part of the example) and then to use the trained (closed) network > to calculate y with only u as an input variable. What is seen in the second > part of the example that they still use part of the output (y1) as input > (beside the normal input: u1).
> How can I do use the trained (closed) narx_network to calculate y1 with > only u1 as input?
It has already been done above. Although y1 is an input to preparets, only the 2 delay initial conditions consistent with d2 = [1 2 ] are used.
1. Type the command "narx_net" and store the listing in a file.
2. Type the command "narx_net_closed" and store the listing in another file.
3. Compare the differences in the two listings and you should get a better feel for what is accomplished by the closeloop command.
Hope this helps.
Greg

Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Asked:

on 19 Aug 2012

Community Treasure Hunt

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

Start Hunting!