Returns a new function that computes both the output of f and its gradient in a
single forward+backward pass. The result is a named list with elements value (the
original return value of f) and grad (the gradients, structured like the inputs or
the wrt subset).
Arguments
- f
(
function)
Function to differentiate. Arguments can be tensorish (AnvilTensor) or static (non-tensor) values. Must return a single scalar float tensor.- wrt
(
characterorNULL)
Names of the arguments to compute the gradient with respect to. Only tensorish (float tensor) arguments can be included; static arguments must not appear inwrt. IfNULL(the default), the gradient is computed with respect to all arguments (which must all be tensorish in that case).