Run the following steps to implement fine-tuning (with transfer learning) using keras.
- Define the train and test directories along with the size that the input images will get resized to before training:
train_dir = 'images/flower_photos/train'test_dir = 'images/flower_photos/test'image_size = 224
- Load the pretrained VGG16 network, but without the top FC layers:
vgg_conv = VGG16(weights='imagenet', include_top=False, input_shape=(image_size, image_size, 3))
- Freeze all the convolutional layers except the last two convolutional layers, along with the FC layers, to reuse the pretrained weights for those layers (without retraining them):
for layer in vgg_conv.layers[:-2]: layer.trainable = False
- Now let's verify the status ...