Conv LSTM input size mismatch error

2 views (last 30 days)
Shraddha Naidu
Shraddha Naidu on 9 May 2020
Answered: NGR MNFD on 2 Jul 2021
I have a cell array of dimension tIN{2000,1} and each element in the cell array is a 100x21 the ouput to that is tOUT{2000,1} with each element also of dimensino 100x21
when training I get the error Invalid training data. Responses must be a matrix of numeric responses, or a N-by-1 cell array of sequences, where N is
the number of sequences. The feature dimension of all sequences must be the same.
How do I fix this?
Error in CONv (line 23)
net = trainNetwork(tIN,tOUT,lgraph,options);
The current code is:
% Define Network Layers
layers = [sequenceInputLayer([100,21,1],'Name','input')
sequenceFoldingLayer('Name','fold')
convolution2dLayer(5,20,'Name','Conv')
maxPooling2dLayer([4 4],'Stride',2,'Name','max')
sequenceUnfoldingLayer('Name','unfold')
flattenLayer('Name','flat')
lstmLayer(100,'Name','lstm','OutputMode','Sequence')
dropoutLayer(0.2,'Name','drop')
fullyConnectedLayer(1,'Name','fc2')
regressionLayer('Name','output')];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'fold/miniBatchSize','unfold/miniBatchSize');
%Training Options
options = trainingOptions('adam', ...
'InitialLearnRate',0.0001, ....
'ExecutionEnvironment','cpu', ...
'MaxEpochs',100, ...
'Plots','training-progress','Shuffle','every-epoch','L2Regularization',0.0005);
net = trainNetwork(tIN,tOUT,lgraph,options);

Answers (3)

Harsha Priya Daggubati
Harsha Priya Daggubati on 12 May 2020
Hi,
I guess you are trying to do sequence to sequence classification of your data using LSTM's. From the data you provided, I can infer you have a training set with 2000 samples, where each sample has 100 features, with 21 values for each feature. Similarly the Responses/labels is also a 2000 x 1 cell array.
I doubt the issue is with the elements of your responses being a cell array of 100 X 21. It is usually expected to be 1 X 21.
You can refer to HumanActivityTrain dataset in MATLAB to help you organise your data.
  1 Comment
Shraddha Naidu
Shraddha Naidu on 12 May 2020
I am actually trying to do a sequence to sequence regression so I need a 100x21 output. Is there a way around it?

Sign in to comment.


Harsha Priya Daggubati
Harsha Priya Daggubati on 12 May 2020
As far as I know, you will be able to assign one class at each time step based on the feature values. So you would need 100 X 21 response for each sample.
This example speaks the same too.
  1 Comment
Shraddha Naidu
Shraddha Naidu on 12 May 2020
This link follows a regression and not classification.
But it does not implement convolution?

Sign in to comment.


NGR MNFD
NGR MNFD on 2 Jul 2021
Hello . I hope you have a good day. I sent the article to your service. I implemented the coding part in the MATLAB software, but to implement my network, two lines of setlayers, training MATLAB 2014 give me an error. What other function do you think I should replace? Do you think the codes I wrote are correct?( I used gait-in-neurodegenerative-disease-database in physionet website.) Thanks a lot

Categories

Find more on Image Data Workflows 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!