TensorFlow
TensorFlow is Google's open-source ML framework for training and deploying models on servers, browsers, and phones, with Keras as its high-level API.
TensorFlow is an open-source framework for machine learning (ML) that Google released in November 2015 under the Apache 2.0 license, after the Google Brain team built it for internal research and products. Programs for deep learning and other numerical work express computation as operations on tensors, multidimensional arrays of numbers, and TensorFlow differentiates them automatically, compiles them into optimized graphs, and runs them on CPUs, GPUs, and TPUs. Its ecosystem covers the whole MLOps path from training to model deployment: Keras for defining models, TensorBoard for tracking experiments, TensorFlow Serving for model serving in production, TensorFlow.js for browsers, and LiteRT, formerly TensorFlow Lite, for phones and embedded devices running edge AI. With TensorFlow 2.21 in March 2026, Google said future TensorFlow work would focus on security and bug fixes, dependency updates, and community contributions, and pointed new generative AI projects to Keras 3, JAX, or PyTorch.
How TensorFlow Works#
TensorFlow 1.x had users build a static computational graph first and then execute it in a session. TensorFlow 2.0, released in 2019, made eager execution the default, so operations run immediately like ordinary Python code, and kept graphs as an optimization: a function decorated with tf.function is traced once per input signature into a graph that TensorFlow can optimize, compile with the XLA compiler, and save in the SavedModel format for deployment without Python. tf.GradientTape records the operations of a forward pass so TensorFlow can compute gradients for backpropagation and gradient descent. This code does both:
import tensorflow as tf
w = tf.Variable([[1.0], [-2.0]])
x = tf.constant([[3.0, 4.0]])
@tf.function # trace the Python function into a TensorFlow graph on the first call
def loss_fn(x):
print("Tracing") # Python code runs only while tracing, not on every call
return tf.reduce_sum((x @ w) ** 2)
# Record operations on a tape to compute the gradient of the loss with respect to w
with tf.GradientTape() as tape:
loss = loss_fn(x)
gradient = tape.gradient(loss, w)
loss_fn(x) # same input shape and dtype: reuses the traced graph without printing
print(f"loss {loss.numpy()}, gradient {gradient.numpy().ravel()}")It prints Tracing once and then loss 25.0, gradient [-30. -40.]: the second call ran the cached graph without executing the Python body, and the gradient of (3w₁ + 4w₂)² at w = (1, -2) is 2 × (-5) × (3, 4). For distributed training, tf.distribute strategies replicate a model across multiple GPUs, TPU slices, or machines.
The TensorFlow Ecosystem#
- Keras: The high-level API for defining layers and models and training them with
fit. Since TensorFlow 2.16, installing TensorFlow installs Keras 3, which also runs on JAX and PyTorch. - TensorBoard: A dashboard for loss curves, metrics, histograms, and model graphs during training. It also reads logs written by other frameworks, and TensorFlow 2.21 no longer installs it as a dependency.
- TensorFlow Serving: A serving system that loads SavedModels and answers prediction requests over gRPC or REST, with versioning for hot model swaps.
- TFX: A pipeline framework for production machine learning that chains data validation, training, evaluation, and pushing an approved model to serving.
- TensorFlow.js: Runs and trains models in the browser and in Node.js, so inference can happen on the user's device without sending data to a server.
- LiteRT: Google's on-device runtime for Android, iOS, embedded Linux, and microcontrollers, renamed from TensorFlow Lite in September 2024. It runs
.tflitemodels converted from TensorFlow, PyTorch, or JAX, with acceleration on mobile GPUs and NPUs.
TensorFlow vs. PyTorch and JAX#
- PyTorch vs. TensorFlow: PyTorch has been eager-first from the start, with
torch.compileadding graph compilation. It is the default framework for most new research code and open-weight models, while TensorFlow's strength is its mature deployment stack for servers, browsers, and mobile devices. - JAX: Google's NumPy-style library of composable transformations,
gradfor derivatives,jitfor XLA compilation, andvmapfor vectorization. Google trains its Gemini models with JAX. - Keras: A high-level API rather than a separate engine. Keras 3 code runs on TensorFlow, JAX, or PyTorch, so a model definition does not tie a project to one framework.
Converting Models for TensorFlow Runtimes#
Models trained in other frameworks reach TensorFlow's deployment tools through converters: onnx2tf rebuilds an ONNX graph as a TensorFlow SavedModel, jax2tf wraps JAX functions as TensorFlow functions, and Google's LiteRT Torch converter produces LiteRT models directly from PyTorch. Ultralytics YOLO models are written in PyTorch, and their export mode uses these paths for YOLO26: format="saved_model" exports ONNX and converts it with onnx2tf into a SavedModel for TensorFlow Serving, format="edgetpu" compiles an INT8 model for Coral Edge TPUs, and format="litert" uses LiteRT Torch, so it needs no TensorFlow installation. This code runs the SavedModel export:
from ultralytics import YOLO
# Load the smallest YOLO26 detection model
model = YOLO("yolo26n.pt")
# Convert through ONNX to a TensorFlow SavedModel directory
path = model.export(format="saved_model")
print(f"SavedModel: {path}")The export writes a yolo26n_saved_model folder, which tf.saved_model.load loads in Python and Ultralytics YOLO itself can run with YOLO("yolo26n_saved_model").










