Machine Learning: Training vs Teaching

Machina
Machine Box
Published in
4 min readOct 24, 2017

In machine learning, we often hear about how models are trained. But what does this really mean?

Training a Neural Network Model to do classification

In order to train a machine learning model, you need training data. This is data that is representative of the different kinds of things you want your machine learning model to be able to predict.

Training a machine to tell you the differences between Bananas and Apples

Suppose you’re training a model to detect different kinds of fruit in an image (for example, bananas and apples). Your training data would be a large set of labeled images representing each fruit you want to be able to detect, typically a few thousand images per type.

For neural networks (very common for image classification), the training data is fed into the network via a layer of input units, which triggers layers of units (also referred to as nodes) beneath it, eventually arriving at the output units. Not all units will be triggered every time. Each unit receives input from a layer above it, which is multiplied by the weights of the connections the data travels upon. Each unit adds up all the input it receives, and when it reaches a certain threshold, it fires and triggers the units below it, eventually propagating to the output.

These outputs are then compared to what they were expected to be based on the training data. The difference between the output and the intended output is used to modify the weights of the connections in the network. This process happens many times until the intended output matches the actual output.

You can try to do it yourself with tensorflow playground and see how classification works.

Tensorflow playground helps you to understand Neural Networks

Once training is complete, you can present the model with an image of a fruit (an Apple or a Banana), it has never seen before, and get back an answer as to what the fruit is. It is important to note that the model won’t be able to identify fruits you didn’t train it with.

A critical piece of training machine learning models is the compute resources it requires. The calculations required to train neural networks are best handled on GPUs (rather than CPUs), which are expensive to run. In use cases where the model will need to be trained consistently, for example in object tagging or facial recognition, the cost of the resources and the knowledge to do it, may be prohibitive.

“Teaching” — how we use one-shot learning

One of the goals of Machine Box is to offer machine learning models in cost-effective ways, so that an organization of any size can have access to state-of the-art AI. One method in which we accomplish this is by enabling Teaching instead of training.

If you’re familiar with Machine Box’s API, you’ve probably noticed the /teach endpoint for both Facebox and Tagbox. This lets you show the neural network inside each box something new, give it a label (such as a person’s name or a type of fashion), and teach it to recognize them in images it has never seen.

How teaching works

Instead of training a model to solve a specific task like classifying Bananas vs Apples, we trained our neural network model (Tagbox) to know how to recognize visual patterns present in the world today. It was a resource intensive task! But we only had to do it once.

Let’s say you now want Tagbox to be able to recognize dragonfruit. Using the /teach endpoint, you can give Tagbox 3 or 4 sample images of dragonfruits.

Because our model already knows about the world of recognizing visual patterns, it doesn’t need to re-train the whole model to be able to perform well in recognizing new categories of images, it only has to re-map its knowledge to say: oh! this pattern looks like a dragonfruit.

With very few samples, and no training at all, the model is able to do one-shot or multiple-shot classification. We call this teaching.

Taught Tagbox an image of dragonfruit, then ran /check with a different image pictured above.

One benefit is that you can teach your boxes with only one image. Your organization doesn’t necessarily have to hire a data scientists to put together a robust training set so that Tagbox can categorize your images by a new classification.

Another benefit is that you won’t have to spend an outrageous amount of money training with GPUs every time you want to teach your system a new task or a new face on your dataset.

Combined with the dead simple APIs, and the advantages of using Docker, this will save you a lot of time and money.

No risk, just try it!

Try Machine Box for free. It’s really easy to get started and takes about 5 minutes to begin integrating machine learning into your product or services.

Each box is a Docker container that you can run on your infrastructure, freeing you from having to use public endpoints from various cloud providers to develop with machine learning, or expensive GPUs to enable dynamic prediction based on ever-changing data.

--

--

Machina
Machine Box

I'm Machina - the mascot for Machine Box. Add machine learning features to your applications. Production ready Docker containers that you can deploy and scale.