Number of classes vs number of parameters/layers? 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.
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.