I have used two image net trained models i.e. VGG16 and inception using following lines in python using Keras API; where x is the input image and batch size is for simplicity =1.
VGGbase_model = InceptionV3(weights='imagenet', include_top=False,
input_shape=(299,299,3))
Inceptionbase_model = VGG16(weights='imagenet', include_top=False,
input_shape=(224,224,3))
predictVgg16= VGGbase_model.predict_on_batch(x)
predictinception= Inceptionbase_model.predict_on_batch(x)
I have observed that VGG16 model predict with an output dimension of (1,512) , i understand 512 is the Features as predicted by the VGG16. however the inception model outputs a dimension of 1,8,8,2048. I understand 2048 is the feature vector as predicted by inception , but what is 8,8 and why VGG16 only have two dimensions while inception have 3. Any comments please.
The default input size for this model is 224x224. Note: each Keras Application expects a specific kind of input preprocessing.
For Inception-v3, the input needs to be 299×299 RGB images, and the output is a 2048 dimensional vector.
The number of learnable parameters in VGG16 is found to be 40,96,000 of 1000 class problems on ImageNet applications with 224 × 224 sized ... ... VGG16 also could not yield better result while training, we went for VGG19. Pictorial representation of final models are given in Fig.
What is VGG16 used for. VGG16 is object detection and classification algorithm which is able to classify 1000 images of 1000 different categories with 92.7% accuracy. It is one of the popular algorithms for image classification and is easy to use with transfer learning.
You can view all layers size by just typing:
print(Inceptionbase_model.summary())
print(VGGbase_model.summary())
of you can see it here: InceptionV3, vgg16
InceptionV3
has shape (None,8,8,2048)
at the last convolutional layer and vgg16
(None, 7, 7, 512)
. If you want to get features from each model you can do that by calling the model with include_top=False
and pooling='avg'
or pooling='max'
(this will add a pooling layer at the end and will output 2048 features for the InceptionV3
model and 512 for vgg16
.
ex.
img_shape=(299,299,3)
Inceptionbase_model = InceptionV3(input_shape=img_shape, weights='imagenet', include_top=False, pooling='avg')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With