MATLAB Answers

error with classes in network classification layer

11 views (last 30 days)
Matpar on 19 Feb 2020
Commented: Matpar on 4 Mar 2020
Hi all matlab folk,
I am seeking some assistance in solving this challenge and move forward! for some reason I am not getting this and I am in need of some assistance!
This error persists no matter if i set the classification layer to auto and I am finding it challenging to move past this phase of the network!
please see layers! then check the error at the bottom
thanx in advance!
Error using vision.internal.cnn.validation.checkNetworkClassificationLayer (line 11)
The number object classes in the network classification layer must be equal to the number of classes defined in the input
trainingData plus 1 for the "Background" class.
Error in trainRCNNObjectDetector>checkNetworkAndFillRemainingParameters (line 290)
vision.internal.cnn.validation.checkNetworkClassificationLayer(analysis, trainingData);
Error in trainRCNNObjectDetector (line 256)
params = checkNetworkAndFillRemainingParameters(trainingData, network, params);
Error in test19 (line 54)
rcnn = trainRCNNObjectDetector(Wgtruth, Newlayers, options, 'NegativeOverlapRange', [0 0.3])
this is my layers
Newlayers = [
imageInputLayer([32 32 3],"Mean",[],"Normalization","zerocenter", "Name","imageinput")
convolution2dLayer([5 5],32,"Name","conv","BiasLearnRateFactor",2,"Padding",[2 2 2 2],"WeightsInitializer","narrow-normal")
maxPooling2dLayer([3 3],"Name","maxpool","Stride",[2 2])
convolution2dLayer([5 5],32,"Name","conv_1","BiasLearnRateFactor",2,"Padding",[2 2 2 2],"WeightsInitializer","narrow-normal")
averagePooling2dLayer([3 3],"Name","avgpool","Stride",[2 2])
convolution2dLayer([5 5],64,"Name","conv_2","BiasLearnRateFactor",2,"Padding",[2 2 2 2],"WeightsInitializer","narrow-normal")
averagePooling2dLayer([3 3],"Name","avgpool_1","Stride",[2 2])

Accepted Answer

Srivardhan Gadila
Srivardhan Gadila on 4 Mar 2020
Please refer to the following workflow: Create R-CNN Object Detection Network.
The total number of classes the RCNNdetector should detect will be the number of object classes you want to detect plus an additional background class. So try changing the outputSize argument of the fullyConnectedLayer to 3 (in this particular case)
  1 Comment
Matpar on 4 Mar 2020
Hi Srivardhan Gadila, I solved this and your answer is what I actually did! I messed around changing the values but one thing that was throwing the errors was the procedure of the transfer learning. This was in the wrong place based on the stepwise progression whilst creating the network layers. Thank you very much for responding and acknowledging me

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by