LSTM input size mismatch

2 ビュー (過去 30 日間)
Xiaoran Li
Xiaoran Li 2020 年 5 月 22 日
回答済み: Srivardhan Gadila 2020 年 5 月 26 日
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

回答 (1 件)

Srivardhan Gadila
Srivardhan Gadila 2020 年 5 月 26 日
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)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by