tf_quant_finance.math.jacobian

Contents

Last updated: 2023-03-16.

tf_quant_finance.math.jacobian#

View source

Computes the jacobian of func wrt to x.

tf_quant_finance.math.jacobian(
    func, x, unconnected_gradients=None, parallel_iterations=None,
    experimental_use_pfor=True, name=None
)

Args:#

  • func: Python callable accepting one Tensor of shape of x and returning a Tensor of any shape. The function whose jacobian is to be computed.

  • x: A Tensor with respect to which the gradient is to be computed.

  • unconnected_gradients: An enum tf.UnconnectedGradients which specifies the gradient value returned when the given input tensors are unconnected. Default value: None, which maps to tf.UnconnectedGradients.NONE.

  • 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.

  • name: Python str name prefixed to ops created by this function. Default value: None (i.e., ‘jacobian’).

Returns:#

A Tensor with the gradient of y wrt each of x.