Clear Filters
Clear Filters

I cannot get closed loop network to run.

1 view (last 30 days)
Kevin Johnson
Kevin Johnson on 29 Nov 2021
Commented: Kevin Johnson on 29 Nov 2021
%first, I prepare the open network in the usual way
net=narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
% Prepare Data
X = tonndata(inputs,false,false);
T = tonndata(target,false,false);
[x,xi,ai,t] = preparets(net,X,{},T);
% Train on first half of data
% r is the length of the data
% 2 represents the delays
hw=floor(r/2);
x_firsthalf=x(:,1:hw-2);
t_firsthalf=t(1:hw-2);
net = train(net,x_firsthalf,t_firsthalf,xi,ai);
% Get the (in-sample) open loop results on the first half of the data
[yopen,xf,af] = net(x_firsthalf,xi,ai);
% These results are good, as expected.
% Convert to closed loop network
[netc,xi,ai]=closeloop(net,xf,af);
% Get the closed loop results on the second half of the data
x_secondhalf=x(:,hw-2+1:end);
[yclosed,xf,af] = netc(x_secondhalf,xi,ai);
% Returns error message: "Error using network/sim (line 270)
% Number of inputs does not match net.numInputs."
% Yet x_firsthalf and x_secondhalf have the same numbers of input columns.
% What am I overlooking?
  2 Comments
Walter Roberson
Walter Roberson on 29 Nov 2021
But what is size(xf) and size(xi) ?
Hypothethically, the closeloop() might have changed the number of inputs required.
Kevin Johnson
Kevin Johnson on 29 Nov 2021
In [netc,xi,ai]=closeloop(net,xf,af), size of xf is 2x2, and size of xi is 1 x 2. The target column was dropped by closeloop. When I remove it before using netc, netc executes (though the closed loop results are very poor unfortunately!). Thanks for your help.

Sign in to comment.

Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!