Project - Introduction to Transfer Learning (Cat vs Non-cats Project)

15 / 26

Cats vs Non-cats using Transfer Learning - Getting Pre-Trained VGG16 base model

The trained VGG16 model is available with tensorflow.keras.applications. We have imported this as from tensorflow.keras.applications import VGG16 in the Import Modules section.

Now let us see how we could use.

INSTRUCTIONS
  • Write the following code to get the weights of the pre-trained VGG16 model.

    vgg_base = VGG16(weights='imagenet', include_top=False)
    
    vgg_base.trainable=False
    

Explanation:

  • We have got an instance of the VGG16 model which is trained on 'imagenet' data.

  • Since we want to customize it for our purpose of cat-vs-noncat classification, we remove the top layers which are the dense layers.

  • We put the vgg_base layers are not trainable by setting vgg_base to False, so that we could use the same weights of the Convolutional layers as used in the VGG16 imagenet data.

Note- If you face Unable to open file error while loading the model, refer to Input/Output Error(Error no. 5).

Get Hint See Answer


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...