フィルターのクリア

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