← Home

From Frustration to Success in image recognition: the discovery of ‘Transfer Learning’

While working on LearningML image recognition I discovered ‘ transfer learning’, one of the techniques that I have found most useful and powerful in Machine Learning.

The research begins and the potholes appear

The first thing I tried was to reduce the size of the images, transform them into greyscale and represent them as vectors of dimension width x height. I presented these vectors to a neural network that had as input a layer of the same dimension as the vectors, several hidden layers and an output layer with a number of neurons equal to the number of classes to be recognised. The result was disastrous! The classification was poor and most of the time wrong. It was one of the many frustrating moments I had during the development of LearningML.

Convolutional neural networks?!?!?!?!?!

I continued researching and learned that the Feed Foward architecture was not the most suitable for dealing with images. The networks that were having the most success in handling images were the so-called convolutional networks. But even with this type of networks the classification, although improving, was still very poor. The reason was clear, the training data sets were not large enough to successfully train any kind of neural network.

It seemed that my problem was unsolvable. The datasets that students would be able to build when using LearningML would be no more than a few dozen images.

However, I knew that The Teachable Machine was capable of very accurate classifications even with just a few images.

How did he do it?

By researching!

And finally the solution came: it was called Transfer Learning. And what does it consist of? Reusing a pre-trained model in a specific task to apply it to a new task, saving time and resources. In the case of image classification, I used MobileNet, an open source model pre-trained on a large number of categories, as a basis for recognising new objects with little data.

Classify images with MobileNet:

And that’s how I solved the image recognition in LearningML and that’s why this kind of model works so well, because we are riding on the shoulders of giants.