ivy.execute_with_gradients(func, xs, retain_grads=False, f=None)[source]

Call function func with input of xs variables, and return func first output y, the gradients [dy/dx for x in xs], and any other function outputs after the returned y value

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

• xs (sequence of variables) – Variables for which to compute the function gradients with respective to.

• retain_grads (bool) – Whether to retain the gradients of the returned values.

• f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

the function first output y, the gradients [dy/dx for x in xs], and any other extra function outputs

Supported Frameworks: