Beginner's guide for TensorFlow: The basics of Google's machine-learning library

Learn more about TensorFlow, with this glossary for Google's software library designed to simplify the creation of machine-learning models.

How TensorFlow can change the face of machine learning Google's TensorFlow isn't just powerful--it's also open source, and that makes it a key part of the rapid advancement of machine learning.

As machine learning becomes more common for tasks ranging from speech to facial recognition, so the tools to build ML models have become more sophisticated.

TensorFlow is one of the major software libraries designed to simplify the creation of machine-learning models for developers.

It is an open-source, accelerated-math library designed to help developers build and train machine-learning models using a wide range of hardware — CPUs, GPUs, and even specialized chips such as TPUs (Tensor Processing Units).

While TensorFlow was originally designed for use with more powerful machines, it has evolved to be able to create models to run in all sorts of unlikely places, from browsers to low-power IoT devices. Today, TensorFlow can be used with a wide range of programming languages, including Python, Go, C++, Java, Swift, R, Julia, C#, Haskell, Rust, and JavaScript.

SEE: How to build a successful developer career (free PDF) (TechRepublic)

However, while TensorFlow streamlines the creation machine-learning models, learning the basics can still take time. Here are definitions of common terms to help you get to grips with TensorFlow.

Cloud TPU: The name for Google's custom processor, designed to be efficient at carrying out key tasks when training or running a machine-learning model — such as executing matrix multiplications.

Each v2 TPU is capable of carrying out 180 trillion operations per second (teraflops) and sports 64GB of high-bandwidth memory for shuttling data around. The more recent v3 TPUs up the speed further, and are available in pods capable of up to 100 quadrillion — one thousand trillion — operations per second or 100 petaflops.

Datasets: The recommended data pipeline to use with the latest version of TensorFlow, this feeds data into your machine-learning model and splits it into chunks that can be handled by the model.

Eager Execution: This programming environment for TensorFlow makes building machine-learning models more intuitive to most software developers, thanks to its familiar imperative approach to running code.

Using Eager Execution also has the benefit of allowing tasks to be accomplished using fewer lines of code and makes debugging earlier.

This is now the default mode of execution in TensorFlow 2.0.

Keras: Keras offers a high-level API for TensorFlow that streamlines the process of building and training a neural network by splitting the building blocks of the networks into reusable classes and abstracting away some of the details of creating the network.

Since TensorFlow 2.0, Keras is now integrated into TensorFlow and is available as a package via tf.keras.

Graph: TensorFlow handles the many operations needed to train a machine-learning model and to use that trained model to make predictions. These operations, for example matrix multiplications or transforming data inputs into a workable form, as well as how data is passed between these operations, are represented by a dataflow graph, which is modelled behind the scenes when using a high-level API such as Keras or tf.estimator.

Sessions: When training or running machine-learning models, TensorFlow creates sessions that run part of the dataflow graph (see above definition) as needed, parcelling work out between the available distributed hardware, with TensorFlow able to push workloads to CPUs, GPUs, and specialist chips such as TPUs.

Again, much of the complexity of sessions is hidden when using TensorFlow 2.0 and a high-level API such as Keras.

tf.distribute.Strategy: An API that allows users to distribute training for machine-learning models across multiple GPUs, multiple machines or Google's custom TPUs.

The API is designed to allow developers to distribute models across hardware to optimize performance with the minimum of changes to their code.

tf.estimator: This offers a high-level API for using TensorFlow to train, evaluate, run, and export machine-learning models, and is available alongside the newer Keras high-level API.

tf.function: Provides a wrapper to use when writing certain functions in Python that allows you to create a reusable TensorFlow graph that can be called in the same way as a typical Python function. Doing so makes it easier for developers to write conventional Python code when using TensorFlow, and also speeds up repeated calls to these wrapped functions.

Tf_upgrade_v2: This Google utility allows developers to automatically convert their TensorFlow 1.x code to TensorFlow 2.0, although some stylistic and syntactical changes will still need to be made manually.

TensorFlow 2.0: The latest version of TensorFlow, which introduces eager execution by default, and cleans up deprecated APIs in favor of making TensorFlow accessible via the Keras API.

TensorFlow Extended: Designed to be used when users are ready to move TensorFlow machine-learning models from research to production, this is an end-to-end platform for deploying production-ready ML pipelines.

TensorFlow Hub: A repository of pre-trained components of TensorFlow models, covering tasks ranging from text to image classification, which can be loaded into applications using a single line of code.

TensorFlow.js: Google's open-source library for carrying out machine learning using JavaScript. The library can be used by developers to create new machine-learning models, as well as to run or retrain pre-trained models.

TensorFlow.js can be used in JavaScript applications running in the browser, on servers inside a Node.js environment, on the desktop using Electron, and on mobile browsers on Android and iOS devices.

TensorFlow Lite: Used to build, convert, and deploy machine-learning models for low-power platforms such as smartphones, IoT devices, and single-board computers such as the Raspberry Pi.

Additional resources