Filter löschen
Filter löschen

How do I fix this error?

2 Ansichten (letzte 30 Tage)
Nikolas Katsaros
Nikolas Katsaros am 2 Mär. 2023
Kommentiert: Nikolas Katsaros am 3 Mär. 2023
I keep getting this error
"Incompatible input and output sequence lengths. The network must return sequences with the same length as the
input data or a sequence with length one."
when I try to run this 1D CNN:
(For reference I am trying to analyse 320 signals with 2000 time points each)
inputSize = size(xTrain());
numClasses = 2; % Cracked or not cracked
layers = [
sequenceInputLayer(time_points,'Name', 'input','MinLength', 2000)
convolution1dLayer(32,20,'Padding', 'same')
batchNormalizationLayer
reluLayer
maxPooling1dLayer(2,'Stride',2)
convolution1dLayer(64,10,'Padding', 'same')
batchNormalizationLayer
reluLayer
maxPooling1dLayer(2,'Stride',2)
fullyConnectedLayer(256)
reluLayer
dropoutLayer(0.5)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
%----------------------Define training options-----------------------------
options = trainingOptions('adam', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',50, ...
'MiniBatchSize',128, ...
'Shuffle','every-epoch', ...
'ValidationData',{xTest,yTest}, ...
'ValidationFrequency',5, ...
'Verbose',false, ...
'Plots','training-progress');
% Train the network
net = trainNetwork(xTrain, yTrain, layers, options);
This is my first time using these neural networks so I have left all the layers and options in case there is an error in those. Any help would be useful.
Thank you

Akzeptierte Antwort

Matt J
Matt J am 2 Mär. 2023
Shouldn't your input layer be,
sequenceInputLayer(inputSize,'Name', 'input','MinLength', time_points)
  5 Kommentare
Matt J
Matt J am 2 Mär. 2023
Seems like a good question. You should post it! However, if you do, you should attach an example of the training input that triggers the error, so that people can reproduce and study it.
Nikolas Katsaros
Nikolas Katsaros am 3 Mär. 2023
Will do - thank you for your help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by