jac#

ivy.jac(func)[source]#

Call function func, and return func’s Jacobian partial derivatives.

Parameters:

func (Callable) – Function for which we compute the gradients of the output with respect to xs input.

Return type:

Callable

Returns:

ret – the Jacobian function

Examples

With ivy.Array input:

>>> x = ivy.array([[4.6, 2.1, 5], [2.8, 1.3, 6.2]])
>>> func = lambda x: ivy.mean(ivy.square(x))
>>> jac_fn = ivy.jac(func)
>>> jacobian = jac_fn(x)
>>> print(jacobian)
ivy.array([[1.53 , 0.7  , 1.67 ],
...        [0.933, 0.433, 2.07 ]])