TensorFlow

FAQ

Article from Issue 199/2017
Author(s):

Welcome our new artificial intelligence overlords by tinkering with their gray matter.

Q: Let's start at the beginning. What are tensors, and where should they flow?

A: Without getting too bogged down in mathematics, tensor is just a fancy word for multidimensional array. These arrays flow through a series of steps to arrive at some calculation. Basically, TensorFlow is a programming tool for pushing big bits of data through a predefined series of steps.

Q: Ah, that's interesting, but it sounds like an awfully complicated way of programming. Why would I want to go to all the trouble of flowing tensors?

A: TensorFlow isn't really a programming language. It's a toolset for performing intensive mathematical computation. Although it's fairly general purpose, it was created initially for creating neural networks.

Q: A what-network?

A: A neural network is a computational model that's inspired by the way our brains work. Our brains are made up of billions of neurons. Each one on its own is quite simple: It collects values from other neurons, applies a weighting to each value, and combines them through a function to create an output. This output is then sent to all the neurons that are connected to it (which typically aren't the same ones that it got the input values from).

Q: I sort of understand; is there a way to get a better idea of what's going on?

A: Yes! The best beginner's visualization for this that we've come across is the TensorFlow Playground [1], which allows you to run a simple neural network in your browser (Figure 1). The playground has a simple task: Given a pattern of dots where some are orange and some are blue, the neural network has to correctly work out which dots are which color by looking at where they are on the graph. You can change the pattern you're using in the data section on the left-hand side. Some of the patterns are quite simple; others are more complicated (particularly the swirl).

Figure 1: Neural networks can be confusing, but TensorFlow Playground makes it easy to see what's going on.

In the playground, the neural network consists of a set of inputs, one or more hidden layers, and an output. In each layer, there are one or more neurons that combine the output from all the neurons at the previous level and assign a weight to them. (You can see the weighting of a particular link by the boldness of the line connecting two neurons.) In each epoch, data flows through the network, and each time the network correctly classifies a datapoint, the connections that were correct are strengthened.

Click on the play arrow to start training your network, and you should see it gradually get better at classifying the orange and blue dots. Playing with the various settings to see how well different configurations can classify dots can get addictive as it's interesting to see how the different settings can make the machine more or less intelligent.

Q: That's fun, but what an earth could that be used for?

A: This type of problem is known as a classification problem. Given a bit of data, you have to classify it as a particular type. In this case, given a dot, you have to classify it as either orange or blue, which is quite simple, but more complex cases could be recognizing what objects appear in an image or what words appear in a piece of audio. Essentially, any time you need to recognize something, you have a classification problem that potentially could be done in this way.

Q: So all you need to do is set up your neural network, feed in some data, and you can recognize stuff? That sounds awesome.

A: On one level, that's correct, but there's quite a lot involved in the phrase "set up your neural network." For the simple dots classification, most networks manage to be fairly accurate, but when the problems become more complex, the particular parameters, setups, and configurations become vitally important to the accuracy of the classification.

Q: Ah, OK. My machine struggles a bit with the few layers needed to classify the spiral in the playground. How on earth am I supposed to run more complex networks?

A: The web browser version isn't full TensorFlow, and it isn't anywhere near as efficient as running it natively. That said, neural networks can be quite processor intensive. There's a version of TensorFlow that runs on Nvidia GPUs, and you can distribute your programs across many machines.

TensorFlow originated at Google, and the search giant has developed special chips designed to run TensorFlow programs as efficiently as possible.

Q: Developed by Google you say? Does that mean they've fed my search history through a network to try and work out what sort of person searches for obscure Linux error messages and wild mushroom identification features?

A: We couldn't say for sure. It's certainly possible that they use some form of artificial intelligence to try to target advertisements more effectively, but they're also probably moving into the more general area of classification, because the better you can classify something, the easier you can search for it.

Through their subsidiary DeepMind, Google is also pushing into a whole host of other areas including a controversial partnership with Britain's National Health Service (NHS). In 2016, DeepMind started a collaboration with the Royal Free London NHS Trust to work with kidney injuries. Unfortunately, neither the NHS Trust nor DeepMind actually got consent from the patients before running the data through their artificial intelligence systems.

Q: Ugh. This is why we can't have anything nice.

A: The field of artificial intelligence does pose some difficult questions for privacy. After all, doctor's notes are routinely stored on computers, and there are various standards that they have to meet. Does the fact that the computer has some potential level of intelligence affect this? Is there a point where computers are sufficiently intelligent that we have to consider our privacy from them not just their operators?

Q: Invasion of privacy and philosophical questions aside, this all sounds really interesting. I suppose that you need to learn some obscure programming language known only to PhD students before you can get started with TensorFlow?

A: Nope. Python is by far the most popular language for working with TensorFlow, but there are also bindings for C++, Java, and Go. The mechanics of using TensorFlow are actually quite straightforward once you've got your head around the flow graphs. However, understanding what you need to set up to get the artificial intelligence you want can be quite challenging. That said, provided you start slowly and build up your understanding, TensorFlow is within the abilities of the average geek. The getting started guide [2] will, as the name suggests, help you get started (Figure 2).

Figure 2: The TensorFlow website can guide you through learning how to build your own artificial brain.

Infos

  1. TensorFlow Playground: http://playground.tensorflow.org
  2. TensorFlow Getting Started Guide: https://www.tensorflow.org/get_started/get_started

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • TensorFlow AI on the Pi

    You don't need a powerful computer system to use AI. We show what it takes to benefit from AI on the Raspberry Pi and what tasks the small computer can handle.

  • Spam-Detecting Neural Network

    Build a neural network that uncovers spam websites.

  • Programming Snapshot – Mileage AI

    On the basis of training data in the form of daily car mileage, Mike Schilli's AI program tries to identify patterns in driving behavior and make forecasts.

  • Machine Learning Smarts for Shutterbugs

    PhotoPrism offers a combination of a polished, user-friendly interface and an artificial intelligence engine that makes organizing, searching, and sharing photos a breeze.

  • Generative Adversarial Networks

    Auction houses are selling AI-based artwork that looks like it came from the grand masters. The Internet is peppered with photos of people who don't exist, and the movie industry dreams of resurrecting dead stars. Enter the world of generative adversarial networks.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News