LSTM input size mismatch

5 Ansichten (letzte 30 Tage)
Xiaoran Li
Xiaoran Li am 22 Mai 2020
Hi,
I am meeting a trouble when I want to build a network with CNN and LSTM. Basically, I learn and follow from this link: https://uk.mathworks.com/help/deeplearning/ug/classify-videos-using-deep-learning.html. my dataset has 2000 samples (each sample contains 40 points), when I test my custom network, there exists an error on the LSTM layer:
Layer 'lstm': Input size mismatch. Size of input to this layer is different from the expected input size.
Inputs to this layer:
from layer 'flatten' (output size 100)
Attached please find the analysis of my network architecture

Antworten (1)

Srivardhan Gadila
Srivardhan Gadila am 26 Mai 2020
With the following code I was able to construct layerGraph with no errors. Make sure you define the lstmLayer with right input arguments.
inputSize = [1 40 1];
filterSize = [1 3];
numFilters = 5;
numHiddenUnits = 25;
numClasses = 2;
layers = [ ...
sequenceInputLayer(inputSize,'Name','input')
sequenceFoldingLayer('Name','fold')
convolution2dLayer(filterSize,numFilters,'Name','conv','stride',[1 1],'padding','same')
maxPooling2dLayer([1 2],'padding',[0 0 0 0],'Name','maxpool','Stride',[1 2])
sequenceUnfoldingLayer('Name','unfold')
flattenLayer('Name','flatten')
lstmLayer(numHiddenUnits,'OutputMode','last','Name','lstm')
fullyConnectedLayer(numClasses, 'Name','fc')
softmaxLayer('Name','softmax')
classificationLayer('Name','classification')];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'fold/miniBatchSize','unfold/miniBatchSize');
analyzeNetwork(lgraph)

Kategorien

Mehr zu AI for Wireless finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by