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

조회 수: 46 (최근 30일)
%% 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
zahoor m
zahoor m 2023년 12월 1일
Invalid training data. For image, sequence-to-label, and feature classification tasks, responses must be categorical.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sindhu Karri
Sindhu Karri 2021년 7월 13일
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
Shilpa Sonawane
Shilpa Sonawane 2024년 3월 12일
편집: Walter Roberson 2024년 3월 12일
Hello,
categorical command is available in Matlab. Use following link to check how to use it.

댓글을 달려면 로그인하십시오.

카테고리

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