tfmri.math.make_val_and_grad_fn
tfmri.math.make_val_and_grad_fn¶
- make_val_and_grad_fn(value_fn)[source]¶
Function decorator to compute both function value and gradient.
Turns function
value_fn
that evaluates and returns aTensor
with the value of the function evaluated at the input point into one that returns a tuple of twoTensors
with the value and the gradient of the defined function evaluated at the input point.This is useful for constructing functions for optimization.
- Parameters
value_fn – A Python function to decorate.
- Returns
The decorated function.