Formatting input and target data for narxnet as concurrent sequences

12 views (last 30 days)
I am using narxnet to train on and predict time series data. My input is NxT, output is MxT, where T=number of time points. My time series are collected in individual trials of different lengths, so according to the doc on multiple sequences with dynamic neural network, I am combining my trial data into concurrent set of sequences, while at the same padding the shorter sequences.
This gives me the input Xnf as a Tx1 cell array, where T=number of time points in the longest trial. Each of these cells is an NxK matrix, N=dimension of input vector, K=number of trials. If trial k is length t1, then in all cells Xnf(t1+1:end), the k-th column will all be nan.
However, I want to divide my data into train, validation, and test with individual trials as units. For example, trials {1,5,6,7,8} are for training, trials {2,3,4} are for validation, and trials {9,10,11} are for testing.
I can't use any of the divdeFcn schemes to do that with my input format.
I then formatted my input such that XnF(1:i1) correspond to training, XnF((i1+1):i2) correspond to validation, and XnF((i2+1):end) correspond to test.
However, the number of columns in each cell within XnF(1:i1) is equal to the number of trials for training; the number of columns in each cell within XnF((i1+1):i2) is equal to the number of trials for validation. This way I can use use
net.divideFcn='divideind';
net.divideParam.trainInd=1:i1;
net.divideParam.valInd=(i1+1):i2;
net.divideParam.testInd=(i2+1):length(XnF)
However, this does not work and I get the following error from train:
Error using nntraining.setup>setupPerWorker (line 61)
Inputs X{1,1892} and Inputs X{1,1} have different numbers of columns.
This suggest to me all of the inputs need to have the same number of columns, so my input format does not work. How should I format my unequal-length trials of time series for narxnet?
  2 Comments
Allen Yin
Allen Yin on 3 Apr 2018
Further reading on RNN suggests that a good solution would be to reset the network state after training on each sequence. But it is not clear how to do this with narxnet...is this something that can be done?
Greg Heath
Greg Heath on 4 Apr 2018
I've reread this multiple times and still don't understand what you are doing and why. Are you able to get someone to edit or cowrite?

Sign in to comment.

Answers (1)

Allen Yin
Allen Yin on 4 Apr 2018
So I have experiment where I collect behavior variables and neuronal activities in multiple trials. I want to predict the covariates with the neuronal activities.
The trial lengths are different, and the covariates also differ from trial-to-trial. So to train the narxnet, I would for example randomly select 10 trials for training, 5 trials for validation and 5 trials for testing.
When I give the data to the narxnet, I would prefer not to concatenate all 15 training and validation trials together in time, because of the huge discontinuities between one trials' end and another's beginning. Instead, I think the correct approach should be training on one trial, reset the network's state, train on the next trial, reset the state, and so on.
Does this make sense, and is this something I can do easily?
  2 Comments
Greg Heath
Greg Heath on 5 Apr 2018
Edited: Greg Heath on 5 Apr 2018
You have erroneously put your comment into an answer box.
However, your comment does describe the correct procedure.
Good Luck
Greg
christttttttophe
christttttttophe on 17 Feb 2020
Hey Allen, did you ever work this out? If so can you explain how?
I am just not sure how to do multiple 'trials' at the same time in Matlab. Especially because of the unequal length of the trials which seems to really make a difficulty with this.
Best.

Sign in to comment.

Categories

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

Community Treasure Hunt

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

Start Hunting!