You are on page 1of 13

Deep Learning

Transfer Learning

Prakash P VIT , Chennai


Road Map
 Transfer Learning

Prakash VIT Chennai


Transfer Learning
Transfer Learning
Transfer learning is a machine learning technique where a model trained on one task
is re-purposed on a second related task
Transfer learning is a technique whereby a neural network model is first trained on a
problem similar to the problem that is being solved.
One or more layers from the trained model are then used in a new model trained on
the problem of interest.
Develop Model Approach Pre-trained Model Approach
Select Source Task Select Source Model

Develop Source Model Reuse Model


Reuse Model
Tune Model
Tune Model
Transfer Learning
Classifier: The pre-trained model is used directly to classify new images.

Standalone Feature Extractor: The pre-trained model, or some portion of the model, is
used to pre-process images and extract relevant features.

Integrated Feature Extractor: The pre-trained model, or some portion of the model, is
integrated into a new model, but layers of the pre-trained model are frozen during
training.

Weight Initialization: The pre-trained model, or some portion of the model, is


integrated into a new model, and the layers of the pre-trained model are trained in
concert with the new mode
Transfer Learning
VGG16(include_top=True, weights=’imagenet’, input_tensor=None, input_shape=None,
pooling=None, classes=1000) default parameters

include_top (True): Whether or not to include the output layers for the model. You don’t need
these if you are fitting the model on your own problem.

weights (‘imagenet‘): What weights to load. You can specify None to not load pre-trained
weights if you are interested in training the model yourself from scratch

input_tensor (None): A new input layer if you intend to fit the model on new data of a
different size.
input_shape (None): The size of images that the model is expected to take if you change the
input layer.
pooling (None): The type of pooling to use when you are training a new set of output
layers.Optional pooling mode for feature extraction when include_top is False
classes (1000): The number of classes (e.g. size of output vector) for the model.only
to be specified if include_top is True, and if no weights argument is specified.
Transfer Learning : Classifier
A pre-trained model can be used directly to classify new
photographs as one of the 1,000 known classes in the image
classification
Transfer Learning : Pre-Trained Model as Feature Extractor
Preprocessor
A pre-trained model can be used to extract features for a new image. These features
can then be used as input in the development of a new model.
The last few layers of the VGG16 model are fully connected layers prior to the
output layer.
These layers will provide a complex set of features to describe a given input image
and may provide useful input when training a new model for image classification or
related computer vision task.
Transfer Learning : Pre-Trained Model as Feature Extractor in
Model
use some or all of the layers in a pre-trained model as a feature extraction
component of a new model directly
This can be achieved by loading the model, then simply adding new layers.
This may involve adding new convolutional and pooling layers to expand upon the feature
extraction capabilities of the model or adding new fully connected classifier type layers to learn
how to interpret the extracted features on a new dataset, or some combination
Transfer Learning : Pre-Trained Model as Feature Extractor in
Model
Alternately, we may wish to use the VGG16 model layers, but train the new layers
of the model without updating the weights of the VGG16 layers
This will allow the new output layers to learn to interpret the learned features of
the VGG16 model
Transfer Learning : Pre-Trained Model as Feature Extractor in
Model
In Keras you can change the input image dimensions for transfer learning via
input_tensor (None): A new input layer if you intend to fit the model on new data
of a different size
References
 https://medium.com/@
kenneth.ca95/a-guide-to-transfer-learning-with-keras-using-resnet
50-a81a4a28084b

 https://
medium.com/analytics-vidhya/transfer-learning-in-deep-learning-
using-keras-b12e0ca6c459

 https://
medium.com/nerd-for-tech/image-classification-using-transfer-lea
rning-vgg-16-2dc2221be34c
Thanks

Prakash VIT Chennai

You might also like