MATLAB Answers

error with classes in network classification layer

7 views (last 30 days)
Matpar
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])
reluLayer("Name","relu")
convolution2dLayer([5 5],32,"Name","conv_1","BiasLearnRateFactor",2,"Padding",[2 2 2 2],"WeightsInitializer","narrow-normal")
reluLayer("Name","relu_1")
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")
reluLayer("Name","relu_2")
averagePooling2dLayer([3 3],"Name","avgpool_1","Stride",[2 2])
fullyConnectedLayer(64,"Name","fc","BiasLearnRateFactor",2,"WeightsInitializer","narrow-normal")
reluLayer("Name","relu_3")
fullyConnectedLayer(2,"Name","fc_rcnn","BiasL2Factor",1,"BiasLearnRateFactor",5,"WeightLearnRateFactor",8,"WeightsInitializer","narrow-normal")
softmaxLayer("Name","softmax")
classificationLayer('Name','classoutput')]
Newlayers(15)
Newlayers(14)

  0 Comments

Sign in to comment.

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
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