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

11 ビュー (過去 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 Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by