- Ensure that the sequence lengths of "trainD" and "targetD" match. "trainD" should have a size of 6x1x1x100, while "targetD" should be 1x100.
- Reshape "targetD" to have the same sequence length as "trainD". Adjust "targetD" to have dimensions 1x1x1x100.
- Confirm that "trainD" and "targetD" are correctly formatted as cell arrays if required by "trainNetwork".
- Check that "trainD" and "targetD" are appropriately preprocessed to ensure compatibility with the network architecture.
CNN-LSTM regerssion
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Incorrect use of trainNetwork (line 184)
Invalid training data. Sequence responses must have the same sequence length as the corresponding predictors.
numFeatures = 6;
numResponses = 1;
numHiddenUnits = 200;
filterSize = 3;
numFilters = 8;
miniBatchSize = 8;
layers = [ ...
sequenceInputLayer([numFeatures 1 1],'Name','input')
sequenceFoldingLayer('Name','fold')
convolution2dLayer([filterSize 1],numFilters,'Padding','same','Name','conv')
batchNormalizationLayer('Name','bn')
reluLayer('Name','relu')
sequenceUnfoldingLayer('Name','unfold')
flattenLayer('Name','flatten')
lstmLayer(numHiddenUnits,'OutputMode','sequence','Name','lstm')
dropoutLayer(0.1,'Name','drop')
fullyConnectedLayer(numResponses, 'Name','fc')
regressionLayer('Name','regression')];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'fold/miniBatchSize','unfold/miniBatchSize');
options = trainingOptions('adam', ...
'MaxEpochs',250, ...
'MiniBatchSize',miniBatchSize, ...
'GradientThreshold',1, ...
'InitialLearnRate',0.005, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',125, ...
'LearnRateDropFactor',0.2, ...
'Verbose',0, ...
'Plots','training-progress');
net = trainNetwork(trainD,targetD,lgraph,options);
trainD is 6x1x1x100 matrix,targetD is 100x1 matrix
0 Kommentare
Antworten (1)
Himanshu
am 17 Jan. 2025
Hello,
I see that you are facing an error related to mismatched sequence lengths in your training data for a CNN-LSTM regression network.
The following pointers can resolve the issue you are facing:
I hope this helps.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Timing and presenting 2D and 3D stimuli 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!