why i'm getting the following error using fitcecoc

4 visualizaciones (últimos 30 días)
Kuljinder Singh
Kuljinder Singh el 28 de Mzo. de 2019
Comentada: Saira el 11 de Mzo. de 2020
Following is the code:
%%dataset= datastore('D:\mat_project');
imgfolder=fullfile('D:\','mat_project');
dataset = imageSet(imgfolder);
trainingLabel = zeros(1, 11);
personIndex = zeros(1, 11);
[training,test] = partition(dataset,[0.8 0.2]);
%%hog features for training set
trainingFeatures=zeros(size(training,2)*training(1).Count,531036);
featureCount=1;
for i= 1:size(training,2)
for j= 1:training(i).Count
trainingFeatures(featureCount,:)=extractHOGFeatures(read(training(i),j));
trainingLabel(featureCount,:)=training(i).Description;
featureCount=featureCount+1;
end
personIndex(i,:)=training(i).Description;
end
Classifier = fitcecoc(trainingFeatures,trainingLabel);
%%test imaage from test set
person=1;
querImage=read(test(person),1);
queryFeatures = extractHOGFeatures(queryImage);
personLabel = predict(faceClassifier,queryFeatures);
booleanIndex = strcmp(personLabel, personIndex);
integerIndex = find(booleanIndex);
subplot(1,2,1);imshow(queryImage);title('Query Face');
subplot(1,2,2);imshow(read(training(integerIndex),1));title('Matched Class');
Error using classreg.learning.internal.ClassLabel (line 29)
You must pass class labels as a vector.
Error in classreg.learning.classif.FullClassificationModel.prepareData (line 480)
allClassNames = levels(classreg.learning.internal.ClassLabel(Y));
Error in classreg.learning.FitTemplate/fit (line 213)
this.PrepareData(X,Y,this.BaseFitObjectArgs{:});
Error in ClassificationECOC.fit (line 116)
this = fit(temp,X,Y);
Error in fitcecoc (line 329)
obj = ClassificationECOC.fit(X,Y,ecocArgs{:});
Error in example (line 18)
Classifier = fitcecoc(trainingFeatures,trainingLabel);

Respuestas (2)

Rohan Amarapurkar
Rohan Amarapurkar el 28 de Mzo. de 2019
As the error message suggeests, check your trainingLabel variable. Its dimensions must match with the dimensions (number of rows) of the trainingFeatures variable. You also might want to check the for loops again, there could be an error in the way you are allocating values to trainingLabel.
  1 comentario
Kuljinder Singh
Kuljinder Singh el 2 de Abr. de 2019
Your answer is not clear to me. Can you please tell me where to change the code.

Iniciar sesión para comentar.


zinou sell
zinou sell el 17 de Jun. de 2019
i use Deep learning for face recignition and svm as a cllasifier. when i run the program i got this :
Error using classreg.learning.classif.FullClassificationModel.processClassNames (line 176)
Requested class names are not found among passed class labels.
Error in classreg.learning.classif.FullClassificationModel.prepareData (line 492)
classreg.learning.classif.FullClassificationModel.processClassNames(...
Error in classreg.learning.FitTemplate/fit (line 213)
this.PrepareData(X,Y,this.BaseFitObjectArgs{:});
Error in ClassificationECOC.fit (line 116)
this = fit(temp,X,Y);
Error in fitcecoc (line 329)
obj = ClassificationECOC.fit(X,Y,ecocArgs{:});
Error in CNNFaceRec (line 95)
clf = fitcecoc(descriptors,lab,'Learners',t,'FitPosterior',1,...
what should i do ?
thank you
  1 comentario
Saira
Saira el 11 de Mzo. de 2020
How can I solve this error?
Error:
Subscripted assignment dimension mismatch.
trainingLabel(featureCount,:) = TrainingimgSets(i).Description;

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by