PlzHelp:Invalid training data. Predictors must be a N-by-1 cell array of sequences, where N is the number of sequences. All sequences must have the same feature dimension and

1 次查看(过去 30 天)
inputSize = [224 224 3];
filterSize = 5;
numFilters = 20;
numHiddenUnits = 200;
numClasses = 4;
layers = [ ...
sequenceInputLayer(inputSize,'Name','input')
sequenceFoldingLayer('Name','fold')
convolution2dLayer(filterSize,numFilters,'Name','conv')
batchNormalizationLayer('Name','bn')
reluLayer('Name','relu')
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');
miniBatchSize = 32;
options = trainingOptions("adam", ...
'MaxEpochs',3, ...
'MiniBatchSize',32, ...
'InitialLearnRate',0.005, ...
'LearnRateDropPeriod',2, ...
'LearnRateSchedule',"piecewise", ...
'L2Regularization',5e-4, ...
'SequencePaddingDirection',"left", ...
'Shuffle',"every-epoch", ...
'ValidationFrequency',floor(numel(imdsTrain.Files)/miniBatchSize), ...
'ValidationData',{imdsValidation,imdsValidation.Labels}, ...
'Verbose',false, ...
'Plots',"training-progress");
%
net = trainNetwork(imdsTrain.Files,imdsTrain.Labels,lgraph,options);

回答(1 个)

Cris LaPierre
Cris LaPierre 2024-3-1
The error is in how the data is organized in imdsTrain.Labels
It must conform to the following specifications

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by