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
2017년 10월 2일
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
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
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
2020년 3월 23일
Thanks, this error has been resolved.
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);
카테고리
도움말 센터 및 File Exchange에서 Object Detection에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!