# Tensorflow, how many layers does this model have?

I'm very new to machine learning and I'm not sure about Tensorflow implementation of neural network model. How many layers does the model below have?

model = Sequential()


I think the answer is 2, because dropout applies to the input layer, but the input shape is (None, 20) and not 200, so does that Dense layer actually follow a implicit input layer?

because dropout applies to the input layer

What you said is True in terms of behavior but Dropout is implemented as a separate layer i.e. keras.layers.Dropout. We can treat it like any other layer.

model = keras.Sequential()

model.summary()


for layer in model.layers:
print(layer)


so does that Dense layer actually follow an implicit input layer?

Your model is yet not built. Without providing the input shape or fit with data, it can't know the input shape. So, it can't know the number of weights/biases for the 1st layer.

When talking about feed forward neural networks one distinguishes between input layer, hidden layers and output layer. Usually you have a single input and output layer and one or more hidden layers.

In your case, the input layer with 20 input neurons is not explicitly mentioned in the code but its still there. Further, there is one hidden layer with 200 neurons and one output layer with a single neuron.

So I would say you have a three layer network. But maybe there are other conventions on how to count the number of layers in a feed forward neural network. Some might exclude the input layer.