In a course I took about machine learning, we normally used about 2 feature extraction layers for image classification tasks, using MNIST or CIFAR datasets for example.

However, when checking an example on Keras website, there are a lot more layers for feature extraction (model visible here):

enter image description here

I have no idea how one can come up with such a network architecture.

How do we find such model except empirically? Do all these layers actually improve the classification or is this done only for the example of how to build the model?


1 Answer 1


Thus, it depends mostly on the complexity of your data. MNIST or CIFAR contain simple data. It's enough to extract edges (to simplicity, think about it as what the first convolutional layer does), then extract some basic shapes from these edges (let's say it's what a second layer does), then aggregate this information, transform. It's enough to distinguish 0 from 8 on the image.

However, it's not so simple to distinguish e.g. fruits from the image. There are many colours, shapes, and details you must identify and filter to predict it correctly. In such a case, you need more abstractions, so you need more layers to learn it. Also, for bigger pictures, sometimes you should use more layers to reduce their dimensionality to extract features for them.

You can identify a number of layers through your experiments starting from the smallest model. You can observe whether final accuracy increases or not when you add a new layer until it stops. Unfortunately, I don't know any rule of thumb about how many layers exactly you should initiate. It may vary depending on your data and the complexity of the problem. It might be a nice start to look at the architecture of models for similar problems. Scientific literature is rife with profound descriptions of others' experiments.

About the utility of all these layers - of course, sometimes you may have too many layers and the last one or two don't help your model. Sometimes you might have just part of the variables unneeded in a layer. That's when you can utilize a technique called pruning.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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