필터 지우기
필터 지우기

X and Y do not have the same number of observations.

조회 수: 9 (최근 30일)
sun rise
sun rise 2021년 9월 5일
댓글: Walter Roberson 2021년 9월 26일
setup_folders;
sadtrdinfo = dir(sad1train); % Returns both folders and files
% sad = dir(pwd); % Returns both folders and files
sorted_cell_array_of_train_folder_names = setdiff({sadtrdinfo([sadtrdinfo.isdir]).name},{'..','.'}); % Select folder names
% cell_array_of_train_folder_names( strncmp( cell_array_of_train_folder_names, ".", 1 ) ) = []; % Remove '.' and '..'
%sorted_cell_array_of_train_folder_names = sort_nat( cell_array_of_train_folder_names );
% sorted_cell_array_of_train_folder_names = cell_array_of_train_folder_names; % if you don't have sort_nat
whos sorted_cell_array_of_train_folder_names
%----------------
np = numel(sorted_cell_array_of_train_folder_names); % number of subfolders
train_cats = categorical(sorted_cell_array_of_train_folder_names);
Group_Train1 = cell(np,1);
for i = 1 : np
SFN = sorted_cell_array_of_train_folder_names{i};% extract his name
traintifpattern = fullfile(sad1train, SFN, tiffwild);
tifListdinfo = dir(traintifpattern); % list all jpg files
tifList = fullfile({tifListdinfo.folder}, {tifListdinfo.name});
ms1 = numel(tifList); % ms = number of image files found
Group_Train1{i} = repmat(train_cats(i), ms1, 1);
end
Group_Train1 = vertcat(Group_Train1{:});
save('Group_Train','Group_Train1');
>> HOG2
Error using classreg.learning.FullClassificationRegressionModel.prepareDataCR (line 231)
X and Y do not have the same number of observations.
Error in ClassificationSVM.prepareData (line 632)
classreg.learning.FullClassificationRegressionModel.prepareDataCR(...
Error in classreg.learning.FitTemplate/fit (line 217)
this.PrepareData(X,Y,this.BaseFitObjectArgs{:});
Error in ClassificationSVM.fit (line 240)
this = fit(temp,X,Y);
Error in fitcsvm (line 334)
obj = ClassificationSVM.fit(X,Y,RemainingArgs{:});
Error in multisvm (line 29)
models{k} =
fitcsvm(TrainingSet,G1vAll,'KernelFunction','polynomial','polynomialorder',3,'Solver','ISDA','Verbose',0,'Standardize',true);
Error in HOG2 (line 37)
result1= multisvm(Feat1,Group_Train1,Feat2,Group_Test1);
>>
Note that the actual number of photos is 26770
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 9월 5일
We do not know how you read in the files to create Feat1 .
In particular, we do not know that you re-created both Feat1 and Group_Train1 after any change to the directory.

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

채택된 답변

yanqi liu
yanqi liu 2021년 9월 26일
sir, may be use libsvm toolbox can much faster
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 9월 26일
Unfortunately that will not solve problems with the number of samples being wrong.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by