# how many neuron are there in my code?

I have the following snippet

model=Sequential()
model.add(Dense(1000,input_dim=4,activation='relu'))
model.add(Dense(500,activation='relu'))
model.add(Dense(300,activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(3,activation='softmax'))
model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])


I wish to create a diagram from this code: My understanding:

1. there are 4 input layer (input_dim=4)
2. there is 3 output layers (softmax)

part I'm not sure: Are there 4 hidden layers (3 dense and 1 dropout)?

What does it mean the unit represent the output size? (i.e., first layer shows 1000, is it 1000 Nerons?!?)

https://machinelearningknowledge.ai/keras-dense-layer-explained-for-beginners/#1_Units

1. Units The most basic parameter of all the parameters, it uses positive integer as it value and represents the output size of the layer.

so my question is: how many Hidden layers are there and what is the size (number of neurons per layer)

## 1 Answer

there are 4 input layer (input_dim=4)

Input dimension is 4, which means input layer has 4 neurons.

there is 3 output layers (softmax)

It's not three output layers. There is only one output layer and its dimension is three.

For the rest, I've commented after each line

model.add(Dense(1000,input_dim=4,activation='relu')) <-- Hidden Layer 1: 1000 neurons
model.add(Dense(500,activation='relu')) <-- Hidden Layer 2: 500 neurons
model.add(Dense(300,activation='relu')) <-- Hidden Layer 3: 300 neurons
model.add(Dropout(0.2)) <-- Dropout is typically not counted as a hidden layer
model.add(Dense(3,activation='softmax')) <-- Output Layer


So, there are three hidden layers, and one output layer. The dropout is not counted as a hidden layer.

• makes sense now. so is it A: . 4--->1000-->500-->300-->3. Or [B] 4--->1000-->500-->300-->1 (example [0,0,0] . Commented Jun 6, 2022 at 19:20