pythonmachine-learningkerasdeep-learningkeras-layer

Keras: find out the number of layers


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.


Solution

  • model.layers will give you the list of all layers. The number is consequently len(model.layers)