Handle Multiple Sequences with GRU/LSTM Dynamic Neural Networks

6 views (last 30 days)
Chris P
Chris P on 28 Aug 2020
Edited: Chris P on 12 Feb 2021
I am performing system identification using neural networks. My data includes multiple subsets of data (experimental trials) rather than one long continuous dataset. Due to this, I can not simply concatenate the data to train a dynamic neural network since there will be discontinuities. I found this page which gets around this issue when designing a NARX network - https://www.mathworks.com/help/deeplearning/ug/multiple-sequences-with-dynamic-neural-networks.html
However, when I try to use this method with a LSTM or GRU design, i get the following error:
Error using DAGNetwork/predictRNN>iAssertInitialStateIsValidForPredict (line 69)
Incorrect network state. The network expects mini-batches size of 16, but was passed a mini-batch of size 1.
Error in DAGNetwork/predictRNN (line 11)
iAssertInitialStateIsValidForPredict(statefulLayers, dispatcher.MiniBatchSize)
Error in DAGNetwork/predictAndUpdateState (line 123)
[Y, finalState, predictNetwork] = this.predictRNN(X, dispatcher, ...
Error in SeriesNetwork/predictAndUpdateState (line 379)
[this.UnderlyingDAGNetwork, Y] = this.UnderlyingDAGNetwork.predictAndUpdateState(X, varargin{:});
Error in GRU_setup (line 327)
[updatedNet,yy] = predictAndUpdateState(updatedNet,v);
Note that the dimension of 16 is referring to the number of experimental trials used to train the network. I concatenated these trials using the catsamples function and got a 1x3600 cell array with each cell have a double array with dimensions 5x16. The number of inputs I have is 5 and the number of samples per test trial is 3600. Additionally, this is a single output system.
Why does the catsample method work for NARX networks but not for LSTM/GRU networks? What is a good way to organize my discontinuous data for training and execution of a LSTM/GRU network?

Answers (0)

Community Treasure Hunt

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

Start Hunting!