How can we increase the training set?

조회 수: 7 (최근 30일)
deep singh
deep singh 2017년 6월 5일
편집: Phil 2017년 6월 5일
This is the code :
if true
for digit = 1:numel(trainingSet)
numImages = trainingSet(digit).Count;
features = zeros(numImages, hogFeatureSize, 'single');
for i = 1:numImages
img = rgb2gray(read(trainingSet(digit), i));
img = imbinarize(img);
features(i, :) = extractHOGFeatures(img, 'CellSize', cellSize);
end
labels = repmat(trainingSet(digit).Description, numImages, 1);
trainingFeatures = [trainingFeatures; features];
trainingLabels = [trainingLabels; labels ];
end
end
Here it is picking data set from 0-9 folders only, what can we do to increase the data set?, when we are increasing the folders in training set it is giving error as :
Error using vertcat Dimensions of matrices being concatenated are not consistent.
Kindly help that how can we increase the folders in training set???? and how can read all folders in given training set

답변 (1개)

Phil
Phil 2017년 6월 5일
편집: Phil 2017년 6월 5일
I think this is the line that produces the error:
trainingLabels = [trainingLabels; labels ];
But the problem is with this line:
labels = repmat(trainingSet(digit).Description, numImages, 1);
When you include images that have the description '10', repmat produces a numImages x 2 char array, NOT a numImages x 1 char array. You then vertically concatenate that 2-column array with the trainingLabels array, which only has 1-column, hence the error.
To fix this, you can either convert the labels to strings, if that's appropriate for your application; or you can ensure that the number of columns in labels is always two by beginning single digit labels with a zero.
Hope this helps.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by