Why should you use Transfer Learning for your Image Recognition App ?

Isaac Cohen Sabban
The Startup

--

Image recognition is one of the most important deep learning topics today.
We find it in medicine, in Automobile Industry, on Social Networks even on our phones.

The problem whit Image Recognition, is that it requires a lot of resources and a lot of data.
For example, if tomorrow you decide to create an app to differentiate a dog from a man or identify the breed of a dog, if you have few data and few resources this may be difficult.

That’s why we use Transfer Learning.

What is Transfer Learning ?

Transfer learning is a supervised learning technique that reuses parts of a previously trained model on a new network tasked for a different but similar problem.

Let’s take a simple example to explain the transfer Learning. Imagine a person who wants to learn to play piano, he will be able to do it more easily if he plays guitar. He can use his knowledge of music to learn to play a new instrument.

In data science, it’s the same idea.

Training a model can be expensive or it can give a bad score due to lack of data.

In the case of a CNN, the convolutional and pooling layers are considered as a feature extraction step.

Transfer Learning on a CNN

Why should you use Transfer Learning ?

We use transfer learning in two cases :

  • Transfer learning is useful when you have insufficient data for a new domain that you want to handle with a neural network and there is a big pre-existing data pool that can be transferred to your problem.
  • Transfer learning is useful when you dont have enough resources, given that we collect the feature extraction part of a larger model, we only have the classifying part to train.

Is it really so extraordinary ?

In this part, we will rather analyze the results, here we challenged 3 classifiers :

  • A CNN with our own architecture.
  • A CNN with VGG-16 features.
  • A CNN with VGG-19 features.

We have 21584 observations, 8351 dogs and 13233 human faces. The results is for a training on 20 epochs and a batch size of 20.

Results for each CNN

As we can see, the transfer learning has reduced by 17 the training time and multiply between 4.5 and 8 the accuracy.

That’s just awesome !!!

Conclusion

Transfer learning is just the perfect solution if you don’t have enough data to have a good model or if you don’t have the computing power of a Google or a Facebook.

Even if it is mainly use in image processing, it is also widely used in text, notably by using a pre-trained Embedding Matrix.

You can find the notebook on my GitHub.

--

--