Error when using lstm with cnn
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammed Firas
am 19 Jul. 2024 um 17:42
Kommentiert: Walter Roberson
am 19 Jul. 2024 um 18:31
XTrain = single(DL_input_reshaped(:,1,1,Training_Ind));
YTrain = single(DL_output_reshaped(1,1,:,Training_Ind)); XValidation = single(DL_input_reshaped(:,1,1,Validation_Ind));
YValidation = single(DL_output_reshaped(1,1,:,Validation_Ind));
YValidation_un = single(DL_output_reshaped_un);
%% DL Model definition with adjusted pooling and convolution layers layers = [ imageInputLayer([size(XTrain,1), 1, 1],'Name','input','Normalization','none')
convolution2dLayer(3, 64, 'Padding', 'same', 'Name', 'conv1')
batchNormalizationLayer('Name', 'bn1')
reluLayer('Name', 'relu1')
maxPooling2dLayer([3,1], 'Stride', [3,1], 'Name', 'maxpool1')
convolution2dLayer(3, 128, 'Padding', 'same', 'Name', 'conv2')
batchNormalizationLayer('Name', 'bn2')
reluLayer('Name', 'relu2')
maxPooling2dLayer([3,1], 'Stride', [3,1], 'Name', 'maxpool2')
convolution2dLayer(3, 256, 'Padding', 'same', 'Name', 'conv3')
batchNormalizationLayer('Name', 'bn3')
reluLayer('Name', 'relu3')
maxPooling2dLayer([3,1], 'Stride', [3,1], 'Name', 'maxpool3')
flattenLayer('Name', 'flatten') % Flatten to 1D per sample
lstmLayer(200, 'OutputMode', 'last', 'Name', 'lstm1') % LSTM layer
fullyConnectedLayer(512, 'Name', 'fc1')
reluLayer('Name', 'relu4')
dropoutLayer(0.5, 'Name', 'dropout1')
fullyConnectedLayer(1024, 'Name', 'fc2')
reluLayer('Name', 'relu5')
dropoutLayer(0.5, 'Name', 'dropout2')
fullyConnectedLayer(2048, 'Name', 'fc3')
reluLayer('Name', 'relu6')
dropoutLayer(0.5, 'Name', 'dropout3')
fullyConnectedLayer(size(YTrain,3), 'Name', 'fc4')
regressionLayer('Name', 'output') ];
options = trainingOptions('rmsprop', ...
.
.
.
so this error is appear to me
((error useing trainNetwork Invalid training data.
The output size (1024) of the last layer does not match the response size (1).))
so the size or XTrain and YTrain is (features x 1 x 1 x minbatchsize)
1 Kommentar
Walter Roberson
am 19 Jul. 2024 um 18:31
XTrain = single(DL_input_reshaped(:,1,1,Training_Ind));
You are training with (something by 1 by 1 by something-else) data.
The networks probably expect (something by something-else) -- 2D data instead of 4D data.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!