TRANSFER LEARNING
Max Pagels, Data Science Specialist
@maxpagels, linkedin.com/in/maxpagels/
MACHINE LEARNING NEEDS DATA TO WORK
The more, the better. But what if you don’t have a lot of data to work with, and
no time to collect more? Is ML still an option?
IN SOME CASES, YES.
For general regression and classification problems such as face detection and
image recognition, there are lots (but still not enough) of freely available
datasets online that you can use to train your own models.
MNIST
70,000 28x28px labelled images of handwritten digits 0-9
FASHION MNIST
70,000 28x28px labelled images of clothing items (ten classes)
VGG FACE DATASET
Portrait images of 2,622 identities
CIFAR-10
60,000 32x32px colour images belonging to one of ten classes (airplane,
automobile, cat, deer etc.)
CIFAR-100
60,000 32x32px colour images belonging to one of a hundred different classes
GTD
Data from more than 170,000 terrorist attacks worldwide, 1970-2016
FOOD 101
101,000 images of 101 types of food items
YOUTUBE-8M
Over 7 million YouTube videos across 4716 classes
LOTS MORE ON KAGGLE
https://www.kaggle.com/datasets
INSTEAD OF TRAINING MODELS YOURSELF,
YOU CAN ALSO USE PRE-TRAINED ONES
If you use a well known dataset such as MNIST or CIFAR-10, chances are
someone’s already trained a neural network, random forest, or some other
learning algorithm on it with high accuracy.
BUT WHAT IF WE HAVE A SPECIFIC PROBLEM
FOR WHICH NO PRE-TRAINED MODEL EXISTS?
Can we somehow leverage the information learned by some pre-trained
model and adapt it to our specific use case?
EXAMPLE
Say we want to build a food classifier that reliably determine if an image
contains one of two Finnish dishes: fried baltic herring or fried perch?
A model pre-trained on Food 101 has learned a lot about what a fish looks like,
but the dataset doesn’t include images of fried baltic herring or fried perch.
Could we use the wisdom the model has learned about fish in order to make
building our custom model easier?
YES, AND IT’S CALLED TRANSFER LEARNING
The basic idea is to take a pre-trained model that has already learning useful
representations and tailor it to a custom use case.
TRANSFER LEARNING, IN A NUTSHELL
Say you have a pre-trained neural network that you would like to adapt to
your use case. To do transfer learning:
1. Chop off the neurons in the last layer of the model
2. Replace neurons with new ones, one neuron per class you want to predict
(or just one neuron in total if doing regression)
3. Finish training using a dataset of labelled images specific to your problem
Why would you want to do this?
ONE MAJOR REASON
You need less labelled data. A lot less. Usually, 50-100 labelled examples is
more than enough.
HOW DOES ONE IMPLEMENT TRANSFER
LEARNING?
You can do transfer learning quite easily in code using Keras, MXNet,
TensorFlow, CNTK etc: download pre-trained model, freeze weights, remove
last layer, add new layer.
There are, however, ready-made, zero-coding-required cloud services that
can do it for you.
CUSTOMVISION.AI DEMO
Transfer learning as a service
THANK YOU!
Special thanks to Ari Bornstein from Microsoft for the inspiration!
QUESTIONS?

Transfer learning with Custom Vision

  • 1.
    TRANSFER LEARNING Max Pagels,Data Science Specialist @maxpagels, linkedin.com/in/maxpagels/
  • 2.
    MACHINE LEARNING NEEDSDATA TO WORK The more, the better. But what if you don’t have a lot of data to work with, and no time to collect more? Is ML still an option?
  • 3.
    IN SOME CASES,YES. For general regression and classification problems such as face detection and image recognition, there are lots (but still not enough) of freely available datasets online that you can use to train your own models.
  • 4.
    MNIST 70,000 28x28px labelledimages of handwritten digits 0-9
  • 5.
    FASHION MNIST 70,000 28x28pxlabelled images of clothing items (ten classes)
  • 6.
    VGG FACE DATASET Portraitimages of 2,622 identities
  • 7.
    CIFAR-10 60,000 32x32px colourimages belonging to one of ten classes (airplane, automobile, cat, deer etc.)
  • 8.
    CIFAR-100 60,000 32x32px colourimages belonging to one of a hundred different classes
  • 9.
    GTD Data from morethan 170,000 terrorist attacks worldwide, 1970-2016
  • 10.
    FOOD 101 101,000 imagesof 101 types of food items
  • 11.
    YOUTUBE-8M Over 7 millionYouTube videos across 4716 classes
  • 12.
    LOTS MORE ONKAGGLE https://www.kaggle.com/datasets
  • 13.
    INSTEAD OF TRAININGMODELS YOURSELF, YOU CAN ALSO USE PRE-TRAINED ONES If you use a well known dataset such as MNIST or CIFAR-10, chances are someone’s already trained a neural network, random forest, or some other learning algorithm on it with high accuracy.
  • 14.
    BUT WHAT IFWE HAVE A SPECIFIC PROBLEM FOR WHICH NO PRE-TRAINED MODEL EXISTS? Can we somehow leverage the information learned by some pre-trained model and adapt it to our specific use case?
  • 15.
    EXAMPLE Say we wantto build a food classifier that reliably determine if an image contains one of two Finnish dishes: fried baltic herring or fried perch? A model pre-trained on Food 101 has learned a lot about what a fish looks like, but the dataset doesn’t include images of fried baltic herring or fried perch. Could we use the wisdom the model has learned about fish in order to make building our custom model easier?
  • 16.
    YES, AND IT’SCALLED TRANSFER LEARNING The basic idea is to take a pre-trained model that has already learning useful representations and tailor it to a custom use case.
  • 17.
    TRANSFER LEARNING, INA NUTSHELL Say you have a pre-trained neural network that you would like to adapt to your use case. To do transfer learning: 1. Chop off the neurons in the last layer of the model 2. Replace neurons with new ones, one neuron per class you want to predict (or just one neuron in total if doing regression) 3. Finish training using a dataset of labelled images specific to your problem Why would you want to do this?
  • 18.
    ONE MAJOR REASON Youneed less labelled data. A lot less. Usually, 50-100 labelled examples is more than enough.
  • 19.
    HOW DOES ONEIMPLEMENT TRANSFER LEARNING? You can do transfer learning quite easily in code using Keras, MXNet, TensorFlow, CNTK etc: download pre-trained model, freeze weights, remove last layer, add new layer. There are, however, ready-made, zero-coding-required cloud services that can do it for you.
  • 20.
  • 21.
    THANK YOU! Special thanksto Ari Bornstein from Microsoft for the inspiration! QUESTIONS?