NARX with multiple Inputs

14 views (last 30 days)
Mustafa Al-Nasser
Mustafa Al-Nasser on 18 Sep 2019
Commented: Sunil Patidar on 28 Jan 2021
Dear All;
I am trying use NARX for time series prediction, the problem that i have multiple inputs and i receiving the following error:
Error using preparets (line 185)
The number of input signals does not match network's non-feedback inputs.
Error in NN_Prediction (line 48)
[Xs,Xi,Ai,Ts] = preparets(net,inputSeries,{},targetSeries);
How can i resolve it ?
clc ;
clear ;
%% Read input and output values
data=readtable ('FoulingData.xlsx','sheet','AI_Data');
I=[I1 I2 I3];
% Normalization between -1 and 1
[In,ps] = mapminmax(I);
[Tn,ts] = mapminmax(T);
%Data Preparation
N = 3; % Multi-step ahead prediction
% Input and target series are divided in two groups of data:
% 1st group: used to train the network
inputSeries = X(:,1:end-N);
targetSeries = T(1:end-N);
% 2nd group: this is the new data used for simulation. inputSeriesVal will
% be used for predicting new targets. targetSeriesVal will be used for
% network validation after prediction
inputSeriesVal = X(:,end-N+1:end);
targetSeriesVal = T(end-N+1:end); % This is generally not available
% Network Architecture
delay = 2;
neuronsHiddenLayer = 10;
% Network Creation
net = narxnet(1:delay,1:delay,neuronsHiddenLayer);
net.numInputs = 3; % adding an input
net.inputConnect =[1 1 1; 0 0 0]; %connecting 3 inputs to the first layer
[Xs,Xi,Ai,Ts] = preparets(net,inputSeries,{},targetSeries);
net = train(net,Xs,Ts,Xi,Ai);
Y = net(Xs,Xi,Ai);
% Performance for the series-parallel implementation, only
% one-step-ahead prediction
perf = perform(net,Ts,Y);
% Multistep prediction
[Xs1,Xio,Aio] = preparets(net,inputSeries(1:end-delay),{},targetSeries(1:end-delay));
[Y1,Xfo,Afo] = net(Xs1,Xio,Aio);
[netc,Xic,Aic] = closeloop(net,Xfo,Afo);
[yPred,Xfc,Afc] = netc(inputSeriesVal,Xic,Aic);
multiStepPerformance = perform(net,yPred,targetSeriesVal);
legend('Original Targets','Network Predictions','Expected Outputs')
  1 Comment
Sunil Patidar
Sunil Patidar on 28 Jan 2021
Can you try removing the bellow mentioned two lines of codes as this might be changing your network's structure.
net.numInputs = 3; % adding an input
net.inputConnect =[1 1 1; 0 0 0]; %connecting 3 inputs to the first layer
Also, Here is a link to an example workflow of how to perform prediction with a closed loop network. While it is not your exact workflow it may be a helpful example:

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!