Tf.GradientTape
tf.GradientTape is a TensorFlow context manager that records tensor operations so gradients can subsequently be computed automatically.
Deep Learning with R, Third Edition
tf.GradientTape is a TensorFlow context-based API object that records tensor operations for subsequent gradient computation.
- How it is used
- Computes gradients for TensorFlow training steps and image-based gradient ascent.
- How deep it goes
- Demonstrates tape scopes, explicit watching, nested tapes, and gradient retrieval without deriving backpropagation by hand.
- Examples
- Uses a squared variable, a nested-tape motion calculation, a custom Keras training step, and an image gradient-ascent step.
- What you can do after
- Apply it via TensorFlow to retrieve gradients for a custom Keras training step or an image update.
Read how Deep Learning with R, Third Edition explains tf.GradientTape →
Deep Learning with Python, Third Edition
TensorFlow’s context object for recording tensor operations so gradients can later be computed from the recorded graph.
- How it is used
- Computes gradients for TensorFlow calculations in custom training steps and input-image gradient ascent.
- How deep it goes
- Works through variable gradients, explicitly watched constants, nested tapes for second-order gradients, and complete training and gradient-ascent steps.
- Examples
- Uses a squared variable, a watched constant, nested position-and-speed gradients, a Keras training step, and filter-activation maximization.
- What you can do after
- Build it from scratch: calculate gradients in a TensorFlow training step or use image gradients to increase filter activation.
Read how Deep Learning with Python, Third Edition explains tf.GradientTape →
Related concepts
- gradientproduces · A gradient is a vector or tensor of partial derivatives that describes how a function changes with respect to its input variables or parameters.
- TensorFlowused by · TensorFlow is an open-source software platform for numerical computation and machine learning, with tools for building, training, and deploying models.
- computation graphproduces · A computation graph is a directed graph whose nodes represent computational operations or values and whose edges represent data dependencies between them.
- forward passuses · A forward pass is a calculation that propagates inputs through an ordered computational or dependency structure to produce outputs or derived values.
- training stepused by · A training step is an iteration in which a model is updated during training using data and an optimization objective.
- automatic differentiationimplements · Automatic differentiation is a computational technique that evaluates derivatives of a program by systematically applying the chain rule to its elementary operations.
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.

