VGG16: how to use Dense_2 layer as output - python

Asked

Viewed 24 times

-1

I am using vgg16 model for feature extraction

https://github.com/fchollet/deep-learning-models/blob/master/vgg16.py

call the same through function:

model = VGG16(include_top=True, weights='imagenet')

But the function returns the softmax layer if I use the include_top=False I have the return of the last VGG convolution layer.

How could I do model receive the Dense 2 ? layer, in the code there is no argument to give me that result.

1 answer

0


The solution is to generate the VGG16 complete with all layers, and then select the desired layer with get_layer command

modelo = VGG16(include_top=True, weights='imagenet')
nome_camada = 'fc2' #Dense_2 do VGG16
camada_selecionada = Model(inputs=modelo.input, outputs=modelo.get_layer(nome_camada).output)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.