Learn AI with Free TPU Power — the ELI5 way
In this article, you’ll learn how to use Google Colab for training a CNN on the MNIST dataset using Google’s TPUs.

Hold up, what’s a CNN?

In a regular Neural Network, you recognize patterns from labelled data (“supervised learning”), with a structure made of inputs, outputs, and neurons in between. Some are these are connected, but deciding which ones are connected manually doesn’t work well for things like images, since the net doesn’t understand how the pixels are related.

A CNN, or Convolutional Neural Network, connects some of the neurons to pixels that are close together, to start out with some knowing of how the pixels are related.

This is a very high level overview, but if you want to dig into the architecture, check out this guide.

What about MNIST?

MNIST is a dataset of handwritten digits, with a training set of 60,000 examples and a testing set of 10,000 examples. It’s often used in beginner problems.

And what is Google Colab?

Google Colaboratory was an internal research tool for data science, which was released to the public with the goal of the dissemination of AI research and education. It offers free GPU and TPU usage (with limits, of course ;)).

Lastly, what is a TPU?

TPU stands for “Tensor Processing Unit”, an alternative to CPUs (Central Processing Unit) and GPUs (Graphics Processing Unit) that’s especially designed for calculating tensors.

A tensor is an alternative to multidimensional arrays (like in NumPy), and are functions you feed data into. The relationships in a neural network can be easily described and processed in tensors, so a TPU is very fast for this kind of work.

Training and Testing a Model on GPUs and TPUs

Signup for Google Colaboratory. Open up this pre-made GPU vs TPU notebook (credits). When you open it up, TPU backend should be enabled (if not, check Runtime -> Change runtime type -> Hardware Accelerator -> TPU). Run a “cell” using Shift-Enter / Command-Enter. Run all the cells in order, starting from the cell named “Download MNIST”. If it’s successful, the empty [] brackets should turn into [1], [2], [3], and so on.

That’s it! You may run into challenges if you’re doing this long after I wrote the article, and cell [4] (training and testing) will take some time to run its 10 epochs.

Conclusion

Much of the barrier of entry to AI and data science used to be in the infrastructure, for instance getting the necessary compute to train large models.

Nowadays, with tools like Google Colab, it really is as simple as opening and running a notebook in your browser, and not much different from using a Google Doc or spreadsheet.

What Should I Do With This Information?

Now you at least know how to run an AI model easily. If you want to practice on real-world challenges, head on over to bitgrit’s competition platform, with new competitions regularly added. This will train your skills, and act as a means to build up your portfolio.

This article was written by Frederik Bussler, CEO at bitgrit. Join our data scientist community or our Telegram for insights and opportunities in data science.
[]
['Machine Learning', 'Artificial Intelligence', 'Technology', 'Google', 'Data Science']