Jax.grad
jax.grad is a JAX transformation that returns a function computing gradients of a scalar-output function with respect to its inputs.
Deep Learning with JAX
A JAX transformation that returns a derivative-computing version of a function, typically with respect to its first argument by default.
- How it is used
- Calculates gradients for loss functions, parameter updates, autodiff experiments, and composable numerical programs.
- How deep it goes
- Explains functional gradients, argnums, auxiliary outputs, nested parameters, stopping gradient flow, and higher derivatives, while deferring autodiff-mode internals.
- Examples
- Demonstrates linear regression, MNIST loss gradients, Minkowski distance, dictionary parameters, higher derivatives, and per-sample gradients.
- What you can do after
- Apply it via JAX to obtain parameter, selected-argument, nested-structure, higher-order, or per-sample gradients.
Deep Learning with Python, Third Edition
A JAX function that creates a gradient-computing function for differentiable inputs and outputs.
- How it is used
- Computes gradients for loss functions used in array programs, model training, and input-image optimization.
- How deep it goes
- Explains function transformation, scalar-loss constraints, argument conventions, auxiliary outputs, and a worked example without deriving automatic differentiation internals.
- Examples
- Uses a squared scalar loss, structured model state, auxiliary outputs, and stochastic gradient ascent on an input image.
- What you can do after
- Apply it via JAX to create reusable gradient functions for scalar losses and use them in optimization steps.
Read how Deep Learning with Python, Third Edition explains jax.grad →
Also covered in
What to know first
- gradientA gradient is the vector of partial derivatives of a scalar function with respect to its variables, indicating its local rate and direction of change.
- objective functionAn objective function is a mathematical function that assigns values to candidate solutions or parameter settings, which an optimization procedure seeks to minimize or maximize.
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- digital imageA digital image is a digital representation of visual content, commonly encoded as an arrangement of pixels or other graphical elements.
Related concepts
- gradientproduces · A gradient is the vector of partial derivatives of a scalar function with respect to its variables, indicating its local rate and direction of change.
- JAXused by · JAX is a Python library for high-performance array computing, with composable transformations for automatic differentiation, compilation, vectorization, and parallelization.
- automatic differentiationimplements · Automatic differentiation is a computational technique that evaluates derivatives of a program by systematically applying the chain rule to its elementary operations.
- jax.value_and_gradalternative to · jax.value_and_grad is a JAX transformation that creates a function returning both a scalar function’s value and its gradient.
- vectorizationuses · Vectorization is the transformation of data or computations into vector form so they can be processed collectively by vector-oriented operations.
- objective functionuses · An objective function is a mathematical function that assigns values to candidate solutions or parameter settings, which an optimization procedure seeks to minimize or maximize.
Questions about jax.grad
What is jax.grad?
jax.grad is a JAX transformation that returns a function computing gradients of a scalar-output function with respect to its inputs.
Which Manning books explain jax.grad?
Deep Learning with JAX and Deep Learning with Python, Third Edition.
What should I know before learning jax.grad?
Manning books that teach jax.grad usually introduce gradient, objective function, function and digital image first.
What is the difference between jax.grad and jax.value_and_grad?
jax.grad is a JAX transformation that returns a function computing gradients of a scalar-output function with respect to its inputs. jax.value_and_grad is a JAX transformation that creates a function returning both a scalar function’s value and its gradient.
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.

