1
$\begingroup$

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)

enter image description here

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

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

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.