TensorFlow
FAQ
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).
![](/var/linux_magazin/storage/images/issues/2017/199/faq/figure-1/700436-1-eng-US/Figure-11_large.png)
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).
![](/var/linux_magazin/storage/images/issues/2017/199/faq/figure-2/700439-1-eng-US/Figure-21_large.png)
Infos
- TensorFlow Playground: http://playground.tensorflow.org
- TensorFlow Getting Started Guide: https://www.tensorflow.org/get_started/get_started
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
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](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.