# Fundamental questions on CNN and MLP in general [closed]

I have read a number of tutorials and online lectures (link1: https://ujjwalkarn.me/2016/08/11/intuitive-explanation-convnets/) and link2: the webtutorial: http://cs231n.github.io/convolutional-networks/#overview but none of them mention the rationale for selecting a particular design. How do we decide on the following design aspects? In particular the following points are unclear to me and shall be extremely grateful if somebody could walk through the concepts that will help me to design any CNN architecture.

1) If the filter size is 5*5*3 then how come the number of filters, $K=12$? Shouldn't it be 3 -- one for each channel?

2) In the second link, there is a formula - $((W-F+2P)/S)+1$
where $W$ = width of the input image, $F$ = filter size. It is not clear what is the purpose of this formula

3) Is there a rule of thumb/formula for deciding on the number of layers, number of filters, filter size, number of fully connected layers? Or is it purely on the basis of trial and error?

4) Can somebody please explain the intuition and the rationale for designing a CNN architecture for this example -- considering a binary classification problem. For an input RGB image of size 500*500*3, how would you design the architecture -- how many layers, number of filters, size of the filter, how much is the stride, etc.

## closed as too broad by Jan Kukacka, kjetil b halvorsen, mkt - Reinstate Monica, mdewey, Jeremy MilesSep 16 '18 at 19:46

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• you have asked a lot of questions. try to break them up into separate posts. in that way you may get better answers. – Haitao Du Sep 16 '18 at 8:09
• Possible duplicate of Is building deep learning architectures a trial and error scheme? – Jan Kukacka Sep 16 '18 at 8:14
• The formula in 2 computes the width of the output of a convolutional layer with input width W, filter size F, padding P and stride S. – Jan Kukacka Sep 16 '18 at 8:17

1. I'm not sure where you found the $5 \times 5 \times 3$. Maybe it's the size of the input image. In that case the input image does have 3 channels, but we can select how many filters we want the layer to have arbitrarily. Let's say we select $K=12$ filters. Then the output of this layer will have $12$ filters. This way, the next layer will see $12$ channels as its input.
4. Same as before. One thing you could try to do is follow the pretty basic scheme of [conv (+relu) -> conv (+relu) -> max pool] repeat this 2-3 times -> flatten -> fc (+relu) -> dropout -> fc (2 neurons and softmax activation). This, is a decent model which doesn't take much memory and runs relatively fast (compared to more complex CNNs), but can't reach state of the art performance. If you want better results stick with fine-tuning a pre-trained state-of-the-art model.
• A typical 2D convolutional filter is applied to each map separately. If you read the stanford tutorial you posted, it has a great numerical example showing how two feature maps ($K=2$) are computed from a 7x7x3 input image. – MzdR Sep 17 '18 at 19:55