liveBook · Manning

Tf.function

tf.function is a TensorFlow decorator that traces Python functions into executable TensorFlow graphs, optionally applying compilation optimizations.

How 2 Manning books explain it

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

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.