In Keras, how to get the layer name associated with a "Model" object contained in my model?

The key is to first do .get_layer on the Model object, then do another .get_layer on that specifying the specific vgg16 layer, THEN do .output:

layer_output = model.get_layer('vgg16').get_layer('block3_conv1').output


To get the name of the layer from the VGG16 instance use the following code.

for layer in conv_base.layers:
    print(layer.name)

the name should be the same inside your model. to show this you could do the following.

print([layer.name for layer in model.get_layer('vgg16').layers])

like Ryan showed us. to call the vgg16 layer you must call it from the model first using the get_layer method.


One can simply store the name of layers in the list for further usage

layer_names=[layer.name for layer in base_model.layers]