0
$\begingroup$

How to estimate the number of parameters in CNN for object detection? I know that there are some well-known architectures that was trained on a lot of data (AlexNet, ResNet, VGG, GoogleLeNet). But they were trained for example for classifying 1000 classes. Or they were used as backbones in the algorithms like YOLO to localize 80 classes of objects. Now let's say that I want to classify only 5 classes. Or I want to perform object detection and I am interested only in cars and people. I want to detect/classify this small number of objects. So the network must learn only the features of cars and people (instead of learning the features of hundreds of objects).

So my intuition is that I can use smaller network with fewer number of parameters. Correct me if I am wrong. And my second intuition is that the number of layers should not have a big impact. I mean, you shouldn't decrease the number of layers only because you have less classes. Because the network learns more and more sophisticated features in deeper layers. And it wouldn't be able to detect advanced features of cars (or other objects) if you don't have enough layers.

Recently I tried to use CenterNet https://arxiv.org/abs/1904.07850 to detect digits on 64x64 grayscale images and I achieved success having quite simple 900k convnet. Then I tried to use slightly modified GoogLeNet to detect cars using 224x224, 448x448, and 512x512 images. I trained it on 450 images. After a lot of trials and errors I still cannot train a good model. GoogLeNet is quite small network in compare to other well-known architectures, but I heard that it's very good. It was carefully designed to be very powerful despite being small (7M parameters).

So to be clear. My question is about the dependencies between the number of classes and the number of layers and parameters.

$\endgroup$
1
$\begingroup$

You are correct about your first assumption, but not about your second assumption.

More layers does not always mean better pattern detection. The analogy that in the deeper layers the network learns more complex features is an oversimplified one. It is true to some extent, although it is not enough to explain very complex architectures like GoogLeNet.

Moreover, using more layers than neccessary increases the risk of observing vanishing gradients. Because the network is too deep i.e. has too many layers, the gradient will be vanishingly small when backpropagating so many layers in the beginning will not get any significant update during training.

$\endgroup$
2
  • $\begingroup$ Ok, I understand the answer to my second assumption. But I also ask about something else. I have GoogLeNet (22 layers deep) which is great for complicated tasks (like classifying 1000 classes). But I want to classify let's say 4 classes (and I use only few hundreds/thousands images instead of millions). Can I decrease the number of layers (for example delete half of them) without being worried about performance? Can I decrease the number of layers because I have less classes? $\endgroup$
    – Kacper777
    May 28 at 18:29
  • $\begingroup$ @Kacper777 You are correct in that decreasing the number of classes will also mean a decrease in the number of layers. Personally I would try with something less complex, like AlexNet. I believe that changing the last two layers of AlexNet to output 5 classes should be enough. Nevertheless, I believe that you can simplify AlexNet by cutting out some layers or increasing the strides and as long as you output 5 classes in the end, you should get good results. $\endgroup$
    – devidduma
    May 28 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.