1

I have the follow Dense function and I am trying to understand it

Dense(10, input_shape = (28*28, ), kernel_initializer='he_normal'))

Does the following code mean I have 10 nodes in my layer, or 28*28 nodes in my first layer. I asked a friend about this and they said it means you have a input layer of 28*28 that is followed by a hidden layer that has 10 nodes.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Jim John
  • 21
  • 1
  • 2

2 Answers2

1

Yes, your input is a 28*28 array and this dense layer has 10 hidden units with the following initializer for the layer weights: https://keras.io/initializers/#he_normal

Anthony D'Amato
  • 748
  • 1
  • 6
  • 23
0

You friend was right - in fact, you have an implicit input layer of 28*28, followed by a hidden layer of 10 nodes.

This is more visible in the Keras Functional API (check the example in the docs), in which your layer would be written explicitly as 2 layers:

inputs = Input(shape=(28*28,))                         # input layer
x = Dense(10, kernel_initializer='he_normal')(inputs)  # hidden layer

See also my answer in a relevant recent question.

desertnaut
  • 57,590
  • 26
  • 140
  • 166