I have sequence data in a cell with 64x6512 for my CNN although it says input size mismatch on my the first convolutional layer, how do I fix this error?

조회 수: 1 (최근 30일)
I am trying to build a CNN network that will take in sequence data. And I don't know how to fix the input size mismatch.
XTrain is a cell array of 450x1 containing 64x6152 Matrices
While YTrain is a categorical array that pairs with XTrain.
The CNN Network:
XTrain=ClassComp;
YTrain=Label;
layers = [
sequenceInputLayer(64,"Name","sequence")
convolution2dLayer([50 1],10,"Name","conv_1","Padding","same")
convolution2dLayer([3 1],10,"Name","conv_2","Padding","same")
maxPooling2dLayer([5 5],"Name","maxpool","Padding","same")
fullyConnectedLayer(64,"Name","fc_1")
dropoutLayer(0.5,"Name","dropout")
fullyConnectedLayer(10,"Name","fc_2")
softmaxLayer("Name","softmax")
classificationLayer("Name","classoutput")];
options = trainingOptions('sgdm', ...
'ExecutionEnvironment','cpu', ...
'GradientThreshold',1, ...
'MaxEpochs',10, ...
'SequenceLength','longest', ...
'Shuffle','never', ...
'Verbose',0, ...
'Plots','training-progress');
net = trainNetwork(ClassComp,Label,layers,options);
The Error
Caused by:
Layer 'conv_1': Input size mismatch. Size of input to this layer is different from the expected input size.
Inputs to this layer:
from layer 'sequence' (size 64(C) × 1(B) × 1(T))

채택된 답변

Anshika Chaurasia
Anshika Chaurasia 2021년 9월 15일
Hi Javier,
The solution is to apply sequenceFoldingLayer and sequenceUnfoldingLayer.
Refer to this example to better understand where to apply these layers.
Hope it helps!
  댓글 수: 1
Javier Castillo
Javier Castillo 2021년 9월 18일
Hi Anshika,
It seems that the input size mismatch error was fixed although this error would pop up which I am uncertain of how to fix with the responses of my training data. My response array is a 450x1 categorical array which corresponds to my 450x1 training data.
Response Data:
The error that it would show was:
Error using trainNetwork (line 184)
Invalid training data. Responses must be a cell array of categorical response sequences.
Which then I used this type of response instead:
Response Data:
Which gave me the same error.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by