How to resolve this error-Invalid training data. For image, sequence-to-label, and feature classification tasks, responses must be categorical.

%% Totla RGB images=55, img4training size=35x60x3x55, YL=training Labels- 55x1
load traindata1.mat;
layers = [
imageInputLayer([35 60 3])
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(10)
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',4, ...
'Shuffle','every-epoch', ...
'Verbose',false, ...
'Plots','training-progress');
YL=[ones(1,28) zeros(1,27)]';
net = trainNetwork(img4training,YL,layers,options);
Error using trainNetwork (line 184)
Invalid training data. For image, sequence-to-label, and feature classification tasks, responses must be categorical.
Error in IMP1 (line 37)
net = trainNetwork(img4training,YL,layers,options);

1 Kommentar

Invalid training data. For image, sequence-to-label, and feature classification tasks, responses must be categorical.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Hii,
In the trainNetwork function the response input(YL) should be an categorical array, instead it is defined as an array.
Refer to below documentation links for more information on categorical array,trainNetwork.

3 Kommentare

Yes mam,
I have done it as a categorical & it works.
Thank you so much
Hello Shilpa, how did you fix it as categorical?
Hello,
categorical command is available in Matlab. Use following link to check how to use it.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Preprocess Data for Deep Neural Networks finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 7 Jul. 2021

Bearbeitet:

am 12 Mär. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by