In real-world Machine Learning problems, building models for your self is great and can be very powerful. But, for some problems, you can be limited by the data you can get. And not everybody has access to massive datasets or you compute power is not good enough for training that’s effective. Transfer learning can help solve this, where people with models trained on large datasets train them so you can use trained results or you can use the features they have learned and apply them to your own model to solve your own problems.
How Transfer Learning improve results
Transfer Learning is an optimization, a shortcut to saving time, or getting better performance. There are three ways Transfer Learning can help you get better performance.
1. Higher start :
The performance of Transfer Learning model from start may higher than other models
2. Higher slope :
The rate of improvement of skill during training of the source model is steeper than other models
3. Higher asymptote :
The conveerged skill of Tranfer Learning model is better than other models
Tranfer Learning with Keras to predict Dog or Cat
In this time we’re going to predict which image is dog image and which image is cat image.
First, we need to download pre-trained model where alot image are trained include dog images and cat images.
After downloaded pre-train model we need to setup that’s model to get the learned features (weights), and we need to take only the output(weights) of the last layer in pre-trained model.That’s is msot importance thing when we using Tranfer Learning.
Next, we use the output of the last layer from the pre-trained model as the input of our model to solve our problem, here is predict dog or cat.
Then we got the result with Transfer Learning after 20 epochs are training accuracy: 0.96 and validation accuracy: 0.958. It’s a perfect result.
And here is the result of model without using Transfer Learning after 20 epochs, train accuracy: 0.992 and validation accuracy: 0.697. This model got overfit.
So after compare 2 models, model using Transfer Learning can improve performance and avoid overfit as well.