Modern AI Engineering

Lesson 3.10 · 25 min · video lesson

TensorFlow Explained: Static Graphs and Production ML

The name says it all if you know how to read it: tensors flowing through a graph. But why would anyone describe a program as a graph instead of just running it line by line?

In short: TensorFlow is Google's open-source machine-learning library. It represents computations as dataflow graphs in which operations are nodes and tensors flow along the edges, which lets it optimise the computation, run it on CPUs, GPUs and TPUs, and export it to servers, phones and browsers. TensorFlow 2 runs eagerly like normal Python, records gradients with tf.GradientTape, turns Python functions into fast graphs with tf.function, and offers Keras as its high-level API.

In this lesson

  1. What is TensorFlow?
  2. Tensors and the "flow": dataflow graphs
  3. Two styles: define-then-run and eager
  4. tf.function: turning Python into a graph
  5. Automatic differentiation with GradientTape
  6. Keras: the high-level API
  7. Devices, scaling and deployment
  8. TensorFlow vs PyTorch, and when not to use it
  9. Going one level deeper
  10. Practice: try it yourself

Key terms in this lesson

TensorFlow
Google's open-source machine-learning library built on tensors, dataflow graphs and automatic differentiation.
Dataflow graph
A representation of a program in which nodes are operations and edges carry tensors between them.
Eager execution
Running each operation immediately and returning concrete values, the default in TensorFlow 2.
tf.function
A decorator that traces a Python function into an optimised TensorFlow graph.
GradientTape
A TensorFlow context that records operations so gradients can be computed by reverse-mode autodiff.
Keras
A high-level neural-network API, TensorFlow's official interface for building and training models.
SavedModel
TensorFlow's format for storing a model's graphs and weights for serving or conversion.

This lesson is free. Sign in or create a free account to open it with its video and quiz.

← 3.9 PyTorch Internals: Dynamic Graphs and Autograd · 4.1 Generative AI: Creating Instead of Classifying →