Daily Dose of Data Science – Day 3 – Accelerate Deep Learning using TensorFlow Hub
Time for another Daily Dose of Data Science! Majority of data scientists consider using Transfer Learning from pretrained Deep Learning models whenever they work on problems involving limited data. That’s where TensorFlow Hub comes in, to even further accelerate the usage, discovery and availability of pretrained machine learning models ready for fine-tuning and deployment anywhere! Let’s discuss more about TensorFlow Hub in this article.
TensorFlow Hub is an open source repository of trained machine learning models that let’s you search, discover and use hundreds of trained and tuned ML models which can be deployed anywhere. This helps you to leverage the true collective power of the community, and removes the necessity of training models from scratch for common problems that can be solved using Machine Learning and Deep Learning. Once these ready to deploy models are downloaded at the end system, users can also perform transfer learning by freezing the initial layers of the pretrained models and re-training the final layers to suit it for their own tasks. Before diving in further, please visit https://tfhub.dev/ to explore more about TensorFlow Hub!
How to setup TensorFlow Hub?
Installing TensorFlow Hub is very easy and straight forward, especially if you already have TensorFlow and its latest version installed. You can use the following code snippet to install and use pretrained models from TensorFlow Hub:
!pip install --upgrade tensorflow_hub
import tensorflow_hub as hub
import tensorflow as tf
classifier = tf.keras.Sequential([
hub.KerasLayer("https://tfhub.dev/google/tf2-preview/mobilenet_v2/classification/4",input_shape=IMAGE_SHAPE+(3,))
])
What is great about TensorFlow Hub?
Apart from allowing simple re-usage of pretrained models, it does have much more added advantage, which I tried to list down in following:
#1 – Easy availability of sophisticated model architectures for more difficult tasks other than simple classification or regression like Image segmentation, speech synthesis, contextual language modeling.
#2 – Robust and well documented tutorials and guides available to get started quickly
#3 – Find and Convert regular models to other native edge device formats like TensorFlow.js, TensorFlow Lite, Google Coral.
#4 – Discover models based on problem domain, by publisher, type of data and by the specific type of architecture
These are some of the key benefits that I have experienced. I will strongly recommend everyone to leverage this wonderful platform from TensorFlow and even step forward, publish your models and contribute for the community. Visit https://www.tensorflow.org/hub to find out more! Stay tuned for another daily dose of data science and please feel free to like, share, comment and subscribe to my posts if you find it helpful!