Cell contents assignment to a non-cell array object.
Afficher commentaires plus anciens
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));"
Réponses (1)
James Tursa
le 2 Oct 2017
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 commentaires
Saira
le 23 Mar 2020
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);
Image Analyst
le 23 Mar 2020
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
le 23 Mar 2020
Thanks, this error has been resolved.
Saira
le 23 Mar 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);
Catégories
En savoir plus sur Object Detection dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!