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,greturnsf().value. In backward mode, custom gradients with respect to each input offare computed usingf().gradFunc.The
savefunction passed tofshould be used for saving tensors needed in the gradient. And thesavedpassed to thegradFuncis aNamedTensorMap, which contains those saved tensors.