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));"

回答 (1 件)

James Tursa
James Tursa 2017 年 10 月 2 日

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 件のコメント

Saira
Saira 2020 年 3 月 23 日
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
Image Analyst 2020 年 3 月 23 日
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 2020 年 3 月 23 日
Thanks, this error has been resolved.
Saira
Saira 2020 年 3 月 23 日
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);

サインインしてコメントする。

質問済み:

2017 年 10 月 2 日

コメント済み:

2020 年 3 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by