필터 지우기
필터 지우기

why i'm getting the following error using fitcecoc

조회 수: 13 (최근 30일)
Kuljinder Singh
Kuljinder Singh 2019년 3월 28일
댓글: Saira 2020년 3월 11일
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);

답변 (2개)

Rohan Amarapurkar
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.
  댓글 수: 1
Kuljinder Singh
Kuljinder Singh 2019년 4월 2일
Your answer is not clear to me. Can you please tell me where to change the code.

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


zinou sell
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
Saira 2020년 3월 11일
How can I solve this error?
Error:
Subscripted assignment dimension mismatch.
trainingLabel(featureCount,:) = TrainingimgSets(i).Description;

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

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by