Git Product home page Git Product logo

transfer-learning-using-vgg16-in-keras's Introduction

Transfer-Learning-using-VGG16-in-Keras

Using VGG16 network trained on ImageNet for transfer learning and accuracy comparison

The same task has been undertaken using three different approaches in order to compare them.

Task: Image classification
Dataset: Dogs vs Cats dataset from Kaggle.
Dataset size: 1000 x 2 training images. 400 x 2 validation images.

Data augmentation:

Keras provides ImageDataGenerator class for performing data augmentation. We will use this to augment the data via random transformations. Rotation, scaling, shearing, flipping, zooming are some possible ways. cat data augmentation

First approach:

Training a small convnet from scratch.
Architecture: A very small convnet with few layers and few filters per layer, alongside data augmentation and dropout. Dropout and augmentation help avoid overfitting.

Accuracy: ~80%

Second approach:

Using the bottleneck features of a pre-trained network.
I have used the VGG16 architecture which was pretrained on the ImageNet dataset.
The strategy is to only instantiate the convolutional part of the model, everything up to the fully-connected layers. Then run the model on training and validation data, record the output (bottleneck features), then train a small FC model on top of those features.

Accuracy: ~90%

Third Approach:

Fine-tuning the top layers of a a pre-trained network
Fine-tuning is when you start with a trained network, then retrain it on a new dataset with very minor weight updates. This can be done in three steps:

  • instantiate the convolutional base of VGG16 and load its weights
  • add our previously defined fully-connected model on top, and load its weights
  • freeze the layers of the VGG16 model up to the last convolutional block

Accuracy: 93%+

Notes:

The first and second approaches were run for 50 epochs each. The third was much more computationally intensive and hence was run only for one epoch and yet displayed a very high accuracy.

transfer-learning-using-vgg16-in-keras's People

Contributors

sabareeshiyer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.