Cell contents assignment to a non-cell array object.

trainingFeatures=zeros(size(training,2)*training(1).Count,4680);
featureCount=1;
for i=1:size(training,2)
for j=1:training(i).Count
trainingFeatures{featureCount,:}=extractHOGFeatures(read(training(i),j));
trainingLabel{featureCount}=training(i).Description;
featureCount = featureCount + 1;
end
Index{i}=training(i).Description;
end
show's error on
"trainingFeatures{featureCount,:}=extractHOGFeatures(read(training(i),j));"

Respuestas (1)

This line
trainingFeatures=zeros(etc);
means that trainingFeatures is a double class matrix.
But this line:
trainingFeatures{featureCount,:}=extractHOGFeatures(read(training(i),j));
treats it as a cell array because of the curly braces. Maybe this is what you intended:
trainingFeatures(featureCount,:)=extractHOGFeatures(read(training(i),j));

4 comentarios

How to solve this error?
Error using categorical/subsasgn (line 84)
Cell contents assignment to a non-cell array object.
Error in Trainingcode (line 35)
trainingLabel{featureCount} = TrainingimgSets(i).Description;
Code:
trainingFeatures(featureCount,:) = Features;
trainingLabel{featureCount} = TrainingimgSets(i).Description;
featureCount = featureCount + 1;
personIndex{i} = TrainingimgSets(i).Description;
%% CNN Classifier
layers = [
fullyConnectedLayer(7)
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm','MaxEpochs',20,'InitialLearnRate',1e-4,'Verbose',false);
trainingLabel = categorical(trainingLabel);
net = trainNetwork(trainingFeatures,trainingLabel,layers,options);
Like it says, trainingLabel is not a cell array. How did you define it earlier? Did you do something like this
trainingLabel = cell(1,1);
or was it produced by a function that returns a cell array? I'm guessing not.
Saira
Saira el 23 de Mzo. de 2020
Thanks, this error has been resolved.
Saira
Saira el 23 de Mzo. de 2020
How to solve this error?
Error using trainNetwork>iAssertXAndYHaveSameNumberOfObservations (line 604)
X and Y must have the same number of observations.
Error in trainNetwork>iParseInput (line 336)
iAssertXAndYHaveSameNumberOfObservations( X, Y );
Error in trainNetwork (line 68)
[layers, opts, X, Y] = iParseInput(varargin{:});
Error in Trainingcode (line 57)
net = trainNetwork(trainingFeatures,trainingLabel,layers,options);

Iniciar sesión para comentar.

Preguntada:

el 2 de Oct. de 2017

Comentada:

el 23 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by