The function to evaluate in forward mode, which should return
{value: Tensor, gradFunc: (dy, saved) => Tensor[]}
, where gradFunc
returns the custom gradients of f
with respect to its inputs.
Rest
...args: Tensor[]Generated using TypeDoc
Overrides the gradient computation of a function
f
.Takes a function
f(...inputs, save) => {value: Tensor, gradFunc: (dy, saved) => Tensor[]}
and returns another functiong(...inputs)
which takes the same inputs asf
. When called,g
returnsf().value
. In backward mode, custom gradients with respect to each input off
are computed usingf().gradFunc
.The
save
function passed tof
should be used for saving tensors needed in the gradient. And thesaved
passed to thegradFunc
is aNamedTensorMap
, which contains those saved tensors.