<p>While counting the number of layers in a Neural Network we usually only count convolutional layers and fully connected layers. Pooling Layer is taken together with the Convolutional Layer and counted as one layer and Dropout is a regularization technique so it will also not be counted as a separate layer.</p>
<p>For reference, the VGG16 mode is defined as a 16 layer model. Those 16 layers are only the Convolutional Layers and Fully Connected Dense Layers. If you count all the pooling and activation layers it will change to a 41 layer model, which it is not. Reference: <a href="https://in.mathworks.com/help/deeplearning/ref/vgg16.html" rel="nofollow noreferrer">VGG16</a>, <a href="https://arxiv.org/pdf/1409.1556.pdf" rel="nofollow noreferrer">VGG16 Paper</a></p>
<p>So as per your code you have 3 layers (1 Convolutional Layer with 28 Neurons, 1 Fully Connected Layer with 128 Neurons and 1 Fully Connected Layer with 10 neurons)</p>
<p>As for making it a 10 layer network you can add more convolutional layers or dense layers before the output layers, but it won't be necessary for the MNIST dataset.</p>
How to check the number of layers in a neural network in python and when should we increase the layers?
<p>Please add a minimum comment on your thought, so that I can improve my query. Thanks. -)</p>
<hr />
<p>I am working on the <code>MNIST</code> dataset and write some <code>CNN</code> code. However, I am confused about some of the points with the <code>CNN</code> code. How to know the number of layers in a neural network? With my current understanding, I think this has 6 layers with 4 hidden layers. Is that right? and what if I need to extend to 10 layers? how to do it?</p>
<pre><code>from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Conv2D, Dropout, Flatten, MaxPooling2D

model = Sequential()
model.add(Conv2D(28, kernel_size=(3,3), 
                    input_shape = ...))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(128, activation=tf.nn.relu))
model.add(Dropout(0.2))
model.add(Dense(10, activation=tf.nn.softmax))
</code></pre>