why i'm getting the following error using fitcecoc
조회 수: 4 (최근 30일)
이전 댓글 표시
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);
댓글 수: 0
답변 (2개)
Rohan Amarapurkar
2019년 3월 28일
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.
zinou sell
2019년 6월 17일
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
Saira
2020년 3월 11일
How can I solve this error?
Error:
Subscripted assignment dimension mismatch.
trainingLabel(featureCount,:) = TrainingimgSets(i).Description;
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!