Tf.function
tf.function is a TensorFlow decorator that traces Python functions into executable TensorFlow graphs, optionally applying compilation optimizations.
Deep Learning with R, Third Edition
tf.function is a TensorFlow API that traces Python functions into optimized TensorFlow computation graphs and can request compilation.
- How it is used
- Speeds up repeated TensorFlow computations, including gradient-based optimization steps.
- How deep it goes
- Explains wrapping, graph mode, XLA, first-call overhead, reuse, and debugging trade-offs without detailing compiler internals.
- Examples
- Uses a compiled dense operation and a stochastic gradient-ascent step as concrete examples.
- What you can do after
- Apply it via TensorFlow to compile reusable functions and optionally request XLA acceleration.
Read how Deep Learning with R, Third Edition explains tf.function →
Deep Learning with Python, Third Edition
A TensorFlow decorator that compiles a Python function into a faster executable form, typically graph mode.
- How it is used
- Speeds up repeatedly executed TensorFlow functions by compiling them outside ordinary Python execution.
- How deep it goes
- Explains decorator syntax, graph mode, XLA, first-call overhead, and debugging trade-offs without detailing compiler internals.
- Examples
- Uses a compiled dense layer and a TensorFlow gradient-ascent step as concrete decorator examples.
- What you can do after
- Apply it via TensorFlow to compile a debugged function and optionally enable XLA with jit_compile=True.
Read how Deep Learning with Python, Third Edition explains tf.function →
Related concepts
- code compilationuses · Code compilation is the translation of source code or another formal representation into an executable, intermediate, or lower-level representation.
- graph modeproduces · Graph mode is a TensorFlow execution mode in which functions are represented and optimized as computation graphs before execution.
- jax.jitequivalent to · jax.jit is a JAX transformation that compiles a function, typically through XLA, for optimized execution.
- training stepcontrasts with · A training step is an iteration in which a model is updated during training using data and an optimization objective.
- tf.GradientTapeuses · tf.GradientTape is a TensorFlow context manager that records tensor operations so gradients can subsequently be computed automatically.
- TensorFlowproduces · TensorFlow is an open-source software platform for numerical computation and machine learning, with tools for developing, training, and deploying models.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

