fchollet / deep-learning-models

Keras code and weights files for popular deep learning models.
MIT License
7.32k stars 2.46k forks source link

How to interpret the output of the feature extractor? #40

Open lazywei opened 7 years ago

lazywei commented 7 years ago

Hi,

I followed the instruction on the README to extract feature from an image by using VGG16 model. When I did

features = model.predict(x)

I found the dimension of the features is of (1, 7, 7, 512). I thought for feature extraction, each image should be represented as a single vector? I'm wondering how to interpret this output and the dimension properly?

Thanks.

gugarosa commented 7 years ago

The problem is that on VGG16 the last layer prior to the top classification ones is a Pooling Layer, therefore you are basically getting the output of this layer, which if I'm not mistaken are 512 7x7 pooling windows. You could apply a dense layer after it in order to get a 1D vector, just remember to use it on all the images that you want to extract the features, so it is possible to make a fair comparison between them.