latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
tensorplay.func.grad_and_value
- tensorplay.func.grad_and_value(func: Callable, argnums: int | tuple[int, ...] = 0, has_aux: bool = False) Callable
Returns a function computing both the gradient of
funcand its value.The value comes from the same forward pass the gradient needs, so this costs no more than
grad()alone and saves evaluatingfunctwice.Returns a function producing
(gradient, value), or(gradient, (value, aux))whenhas_auxis set.
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

