Keras: find out the number of layers
15,832
model.layers
will give you the list of all layers. The number is consequently len(model.layers)
Related videos on Youtube
Author by
user673592
Updated on June 04, 2022Comments
-
user673592 over 1 year
Is there a way to get the number of layers (not parameters) in a Keras model?
model.summary()
is very informative, but it is not straightforward to get the number of layers from it. -
Nickolas over 3 years
len(model.layers)
fails to count "sublayers", that is layers that exist within a model that's acting as a layer in your ubermodel.