MATLAB: How are the input weights organized in a nonlinear autoregressive networks with an external input (narxnet)

input weightsMATLABnarxnetneural networknonlinear autoregressive networks with an external inputweight matrices

I have trained a Nonlinear autoregressive networks with an external input using the narxnet() command. The network has 5 input delays and 5 feedback delays and 10 hidden neurons and was created with the following command:
net = narxnet(10:15,10:15,10)
The network was trained to predict a single time series given two time series and the feedback delays as inputs. For research purposes, I am investigating the contributions of the two inputs and feedback delays to the output. To understand relative contributions, it is imperative to first understand the organization of the individual input weight matrices contained in the following commands:
net.IW and net.inputWeights
Given the following example code,
[X,T] = simplenarx_dataset;
net = narxnet(10:15,10:15,10);
[Xs,Xi,Ai,Ts] = preparets(net,X,{},T);
net = train(net,Xs,Ts,Xi,Ai);
here is my question: In the input weight matrices of the above network, how are the inputs and feedback delays organized? Are the input weights the first column(s) in the weight matrix net.IW{1}?
Thanks, Sam

Best Answer

close all, clear all, clc;
net = narxnet(10:15,10:15,10) % Removed semicolon
% net.numInputs = 2 % Input and Output Feedback
% net.numInputDelays = 15 % BUG? Not 2*length(10:15) = 12?
% net.numFeedbackDelays = 0 % Open Loop
% net.numWeightElements = 10 % 10 zero bias weights (I & O not configured)
IWc = net.IW % 2 inputs
LWc = net.LW
bc = net.b
IW = cell2mat(IWc) % BUG? No indication of 2 inputs
LW = cell2mat(LWc)
b = cell2mat(bc)
view(net)
[X,T] = simplenarx_dataset;
[Xs,Xi,Ai,Ts] = preparets(net,X,{},T);
rng(0) % So you can duplicate results
[net tr Ys Es ]= train(net,Xs,Ts,Xi,Ai); % ALWAYS include tr !!!
IWc = net.IW
LWc = net.LW
bc = net.b
IW = cell2mat(IWc) % [10 12] = size( IW)
LW = cell2mat(LWc) % [ 1 10] = size( LW)
b = cell2mat(bc) % [11 1] = size( b)
view(net)
tr = tr % For your edification
% Hope this helps
%

% Thank you for formally accepting my answer
%
% Greg