Machine Learning - MobileNet

Hey there, Lets begin with a story. The real-life story of Colonel Harland Sanders (KFC) who was disappointed umpteen times in his life and still made his dream come true late in his life is really inspiring. He is a seventh grade dropped out who tried many ventures in life but tasted bitter every time. He started selling chicken at his age of 40 but his dream of a restaurant was turned down many times due to conflicts and wars. Later he attempted to franchise his restaurant. His recipe got rejected 1,009 times before the final approval. And soon the secret recipe, “Kentucky Fried Chicken” became a huge hit worldwide. KFC was expanded globally and the company was sold for 2 million dollars and his face is still celebrated in the logos.
Have you stopped your attempts to a venture just because you were rejected or failed a few times? Can you even accept a failure of 1009 times? This story inspires everyone to try hard and believe in yourself until you see success despite how many times you have failed.
Main Content From Here
As we mentioned before, there have been very successful models that have performed very well on the ImageNet competition, such as
- AlexNet
- Inception
- Resonant
In this lesson, we will use a state of the art convolutional neural network called MobileNet.
MobileNet, uses a very efficient neural network architecture that minimizes the amount of memory and computational resources needed while maintaining a high level of accuracy.
This makes MobileNet ideal to work on mobile devices that have limited memory and computational resources. MobileNet was developed by Google and was trained on the ImageNet dataset.

Since it's been trained on ImageNet, it has 1,000 output classes far more than the two we have in our cats and dogs dataset. To perform transfer learning, we'll download the features of MobileNet without the classification layer.

In TensorFlow, the downloaded features can be used as regular KerasLayers with a particular input size. Since MobileNet was trained on ImageNet, we have to match the same input size that was used during training. In our case, MobileNet was trained on RGB images of a fixed size of 224 by 224 pixels. TensorFlow has a repository of pretrained models called TensorFlow hub.

TensorFlow hub also has pretrained models where the last classification layer has been stripped out. Here, you can see a version of MobileNet version two.
Using TensorFlow hub from code is really simple, you can just refer to the URL and then embed the pre-trained model as a KerasLayer in a sequential model.

Then, we simply add our classification layer to the end of our model. Since our cat and dog dataset has only two classes, we'll add a dense layer with two outputs and a softmax activation function to our sequential model.
This dense layer will be our new classifier and it needs to be trained.

We can train our sequential model just as we did previously using the fit method.

Adios. Hasta luego.
More in Making Of Terminator
- Machine Learning - Introduction
- Machine Learning - Celsius to Fahrenheit
- Machine Learning - Celsius to Fahrenheit - Core
- Machine Learning - Celsius to Fahrenheit - Google Colab Code
- Machine Learning - Celsius V Fashion Mnist
- Machine Learning - Convolutional Neural Networks ( CNN )
- Machine Learning - Convolution with color images
- Machine Learning - Deep Neural Network
- Machine Learning - Dense Layer
- Machine Learning - Dropout
- Machine Learning - Fashion Mnist Dataset - Google Colab Code
- Machine Learning - Fashion MNIST dataset - Prologue
- Machine Learning - Going Furthur with CNN Part 1
- Machine Learning - Going Furthur with CNN Part 2
- Machine Learning - Image Augumentation
- Machine Learning - Max & Average Pooling
- Machine Learning - Max Pooling With Color Images
- Machine Learning - Training And Testing
- Machine Learning - Transfer Learning
- Machine Learning - Understanding Convolutional Neural Networks
- Machine Learning - Validation

Sandeep B
Frontend engineer writing about Angular, JavaScript, and the occasional deep dive into whatever's currently breaking my build.