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

3 次查看(过去 30 天)
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

更多回答(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