Keras: How to get layer shapes in a Sequential model

If you want the output printed in a fancy way:

model.summary()

If you want the sizes in an accessible form

for layer in model.layers:
    print(layer.get_output_at(0).get_shape().as_list())

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

Leave a Comment