TensorFlow is Google's open-source machine learning framework designed for building, training, and deploying neural networks at scale. It combines low-level tensor operations with high-level Keras APIs, making it suitable for both research and production. TensorFlow runs on CPUs, GPUs, and TPUs, supports distributed training, and enables deployment to mobile, web, edge devices, and servers via TFLite, TF.js, and TF Serving. The key mental model: TensorFlow executes eager operations by default while @tf.function traces them into optimized computational graphs, with automatic differentiation via GradientTape handling backpropagation for training.
What This Cheat Sheet Covers
This topic spans 32 focused tables and 221 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Model Building APIs
Keras gives you three ways to define a model, and the right one depends on how unusual your architecture is. The Sequential API is the quickest path for a simple stack of layers, the Functional API handles branching graphs with multiple inputs, outputs, or shared layers, and subclassing trades convenience for total control when you need custom forward-pass logic. Most projects start Sequential and graduate as their needs grow.
| API | Example | Description |
|---|---|---|
model = tf.keras.Sequential([ tf.keras.layers.Dense(64, activation='relu'), tf.keras.layers.Dense(10, activation='softmax')]) | β’ Linear stack of layers where each has exactly one input and one output tensor β’ simplest approach for feedforward architectures. | |
inputs = tf.keras.Input(shape=(28, 28, 1))x = tf.keras.layers.Conv2D(32, 3)(inputs)outputs = tf.keras.layers.Dense(10)(x)model = tf.keras.Model(inputs, outputs) | β’ Directed acyclic graph of layers β’ supports multiple inputs/outputs, shared layers, and non-linear topologies. |