Keras: find out the number of layers

user673592 picture user673592 · Jan 15, 2018 · Viewed 12.2k times · Source

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.

Answer

Maxim picture Maxim · Jan 15, 2018

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