Borrar filtros
Borrar filtros

How can we increase the training set?

2 visualizaciones (últimos 30 días)
deep singh
deep singh el 5 de Jun. de 2017
Editada: Phil el 5 de Jun. de 2017
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

Respuestas (1)

Phil
Phil el 5 de Jun. de 2017
Editada: Phil el 5 de Jun. de 2017
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by