Keras: How to get layer shapes in a Sequential model

If you want the output printed in a fancy way:


If you want the sizes in an accessible form

for layer in model.layers:

There are probably better ways to access the shapes than this. Thanks to Daniel for the inspiration.

Leave a Comment