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.
Table 1: Model Building APIs
| 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. |