MATLAB Answers

How can I train multiple sequences in neural network using feedforwardnet?

75 views (last 30 days)
I have 5 pairs (input-output) of time series. I know the way to train multiple time series using a dynamic neural network ( ), however I'd like to use a static neural network (feedforwardnet function) instead. How could I do that?

Accepted Answer

Greg Heath
Greg Heath on 11 Feb 2016
close all, clear all, clc
[ X0 T0 ] = simplenarx_dataset;
X(1,:) = X0(1:end-2); X(2,:) = X0(2:end-1);
X(3,:) = T0(1:end-2); X(4,:) = T0(2:end-1);
T = T0(3:end);
x= cell2mat(X); t = cell2mat(T);
vart = var(t,1)
net = feedforwardnet;
for i =1:10
net = configure(net, x, t);
[ net tr y e ] = train(net,x,t);
NMSE(i,1) = mse(e)/vart;
For your 5 series problem with 4 default 1:2 input and feedback delays,
size(X,1) = 5*4 = 20 and size(T,1) = 5*1 = 5
Hope this helps.
Thank you for formally accepting my answer

Sign in to comment.

More Answers (1)

Dennis on 11 Feb 2016
Edited: Dennis on 11 Feb 2016
Do you mean the "input output and curve fitting" neural network type from nnstart? Since in that network, no delayed information about previous inputs/outputs is used, you can simply add all your datasets in one big matrix:
Example input u and output y (where 1 and 2 are two seperately measured datasets):
u1 = [1 2 3 4 5] y1 = [1 1 1 2 1]
u2 = [2 2 3 2 3] y2 = [3 3 3 4 3]
X = [u1 u2] T = [y1 y2]
and train the nn with input X and output T. Be aware that you still need to convert these matrices to a nn dataset with tonndata(). Watch the dimensions of your data, e.g. if it is a vertical vector instead of the shown horizontal vector. If you are not familiar with the training commands, type in nnstart and let the tool help you.
However, if you want to use a nn as mathematical model for a dynamic system (engineering background, machinery, some electrical filter), then you must use the dynamic ones from the nnstart toolbox "dynamic time series". Since this kind of nn reacts to past events, multiple datasets for training cannot be simply put together - it would look like your physical system would "jump" every time a new dataset it coming. Instead, for dynamic nn you must use catsample to make the training algorithm acknowledge that there are multiple, separated datasets. You can see the effect of catsample in the following screenshot:
  1 Comment
Ghazi Binarandi
Ghazi Binarandi on 12 Feb 2016
I am intending to train a multiple time series using a feedforward neural network. I couldn't put them together into a single big matrix because it is consisted of several separate sequences.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!