Last updated: 2023-03-16.
tf_quant_finance.math.value_and_jacobian#
Computes f(x) and its jacobian wrt to x.
tf_quant_finance.math.value_and_jacobian(
f, x, unconnected_gradients=None, name=None, parallel_iterations=None,
experimental_use_pfor=True
)
Args:#
f: Pythoncallableto be differentiated. Iffreturns a scalar, this scalar will be differentiated. Iffreturns a tensor or list of tensors, by default a scalar will be computed by adding all their values to produce a single scalar. If desired, the tensors can be elementwise multiplied by the tensors passed as thedykeyword argument to the returned jacobian function.x: ATensorwith respect to which the gradient is to be computed.unconnected_gradients: An enumtf.UnconnectedGradientswhich specifies the gradient value returned when the given input tensors are unconnected. Default value:None, which maps totf.UnconnectedGradients.NONE.name: Pythonstrname prefixed to ops created by this function. Default value:None(i.e.,'value_and_jacobian').parallel_iterations: A knob to control how many iterations are dispatched in parallel. This knob can be used to control the total memory usage.experimental_use_pfor: If true, uses pfor for computing the Jacobian. Else uses a tf.while_loop.
Returns:#
A tuple of two elements. The first one is a Tensor representing the value
of the function at x and the second one is a Tensor representing
jacobian of f(x) wrt x.
y:y = f(x).dydx: Jacobian ofywrtx_i, wherex_iis the i-th parameter inx.