I am trying to understand the model.summary()
in keras, I have the code as:
model = Sequential([
Dense(3,activation='relu',input_shape=(6,)),
Dense(3,activation='relu'),
Dense(1),
])
model.compile(optimizer='adam',
loss='mean_squared_error',
metrics=['mae','mape','mse','cosine']
)
And when I print(model.summary())
I get output as
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_16 (Dense) (None, 3) 21
_________________________________________________________________
dense_17 (Dense) (None, 3) 12
_________________________________________________________________
dense_18 (Dense) (None, 1) 4
=================================================================
Total params: 37
Trainable params: 37
Non-trainable params: 0
_________________________________________________________________
None
I cannot understand the meaning of dense_16, dense_17 and dense_18 with respect to my described model input layers.
Those are just the names of the layer that were autogenerated by Keras. To name layers manually, pass a keyword argument name='my_custon_name'
to each layer that you want to name. Note that layer names must be unique inside a model.
Layer names are useful for debugging and to get specific layers in code, for example using model.get_layer(layer_name)
.