Returns a new function that computes both the output of f and its gradient in a
single forward+reverse 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 arrayish (AnvlArray) or static (non-array) values. Must return a single scalar float array.- wrt
(
character|integer|NULL)
Names or positions of the arguments to compute the gradient with respect to. Only arrayish (float array) 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 arrayish in that case).