Transfer Learning — Introduction, Use Cases and Tips to Deploy

Prakash Gupta
4 min readFeb 12, 2021

Written by Prakash Gupta, Rajeev Bajaj, Feb 11, 2021

Brain Network Artificial Intelligence Technology

Transfer Learning is a recognised hack to build high performance deep learning models with limited datasets and much less compute. It’s widely known that deep learning gives great results but that it also needs huge datasets and large compute capacity. Even when deep learning is the best tool to solve a problem, large dataset availability and / or high compute costs can be significant limiting variables. Transfer learning might come to the rescue in such cases.

Transfer learning allows us to take the learnings gained while solving another problem within the same / similar domain and repurpose it to solve our current problem. Teaching python programming to a Java programmer should be relatively easier than teaching a person who does not have any software programming experience. This is an apt simile to explain how transfer learning makes our deep learning job easier.

Use Cases

Transfer learning is heavily used to solve machine vision and Natural Language Processing(NLP) related deep learning problems today.

I still remember how amazed I was to see the first notebook from the fast.ai course (which I took a few years ago) which solved a cats and dogs image classification problem, with great accuracy, using a small dataset and under 2 minutes of training! No prizes for guessing — it used transfer learning with one of the pre-trained ResNet models.

GPT3 is probably the most advanced NLP service (not model!) ever built. It’s 175 billion machine learning parameters are what enable it to do ‘crazy, specific and relevant things ’ that address your requirements- like writing kids stories or creating HTML sites. All you have to do is, teach it with a few examples. Openai, the creator of GPT3, has kept the underlying model under wraps and made it available to partners via apis. Most probably, it uses some sort of transfer learning under the hood to customize the model for each individual customer.

Rise of “Intelligence As A Service”

Think for a moment about the term ‘Intelligence as a Service’. What does it mean? A thinking human/s at work solving your specific problem, sounds about right. Does it necessarily mean that a live human is a precondition to transfer learning from their brain to your use case? Would it be any less intelligent if the intelligence came packaged in a machine learning model? As long as the transfer of learning can be effective at solving a given problem, should it matter if it came from a machine learning model or a live human.

It is our view that, in the coming decade, Machine Learning as a Service will be a distinct subgroup in the SaaS domain with wide ranging applications in different spheres of human activity. GPT3 apis seem to be pointing the way forward in this context. There are quite a few other offerings in the market today on similar lines, like indico for process automation, ultimate.ai for customer service automation. Most such services publicly disclose making use of transfer learning. Starting off with a core model, transfer learning is used to train a custom model for a particular customer, using that customer’s data. As such products scale, learnings from previous trainings’, makes transfer learning all the more effective for future models.

Transfer Learning — Deploying Production Pipeline

Owing to the different use cases which benefit from transfer learning, special care must be taken while deploying the transfer learning pipeline in production. Broadly, transfer learning projects can be divided into two main categories

Offline training

This is typically the case where a model is being developed for just a single entity. An organisation might use transfer learning to develop a model for its internal use or an AI consultant might be building a model for one of its customers. Generally, the workflow in such cases is:

Build the model and start using it in production. Once it’s performance drops, retrain the model and repeat.

A good choice for such scenarios is to set up the workflow for training such models on tools like AWS Sagemaker, Azure ML. These tools are typically invoked using their SDK apis. These invocations can be triggered in different ways — on demand, by engineering teams (either manually or via automated scripts).

Online training

This is the case where models are generated, on the fly, for different customers, using each customer’s datasets. “Intelligence As A Service” machine learning models fall in this category. This requires the complete transfer learning training pipeline exposed as an endpoint, which can be programmatically invoked any time a customer provides new data. Converting your transfer learning training code into a serverless cloud function is a clean, simple and good approach in these cases. Serverless cloud functions give you great scalability and optimal cost as you only pay for your function runtime.

AWS Lambda, Google Cloud Functions, Azure Functions are the most popular serverless cloud frameworks. But, and this is a big but, most of these frameworks are not built with deep learning training in mind. They impose numerous restrictions like no GPU support, just 15 minutes of execution time, 50MB of package size, etc. A table of such limitations for AWS lambda can be found here.

Clouderizer Showcase helps overcome these limitations and challenges. It was built keeping deep learning training and scoring in mind. It allows direct deployment of your Jupyter Notebook (without any code changes) as a serverless cloud function. GPU Functions, long running tasks are some of the other salient features which makes Clouderizer a good choice for deploying your transfer learning training pipeline as a serverless cloud function endpoint. You can signup for a free account and give it a try. In case you have any questions, feel free to reach out to us at info@clouderizer.com

--

--

Prakash Gupta

Passionate about designing and developing scalable software platforms.