cuqi.model.Model.gradient#

Model.gradient(direction, *args, is_direction_par=True, is_var_par=True, **kwargs)#

Gradient of the forward operator (Direction-Jacobian product)

The gradient computes the Vector-Jacobian product (VJP) of the forward operator evaluated at the given model input and the given vector (direction).

Parameters:
  • direction (ndarray or cuqi.array.CUQIarray) – The direction at which to compute the gradient.

  • *args (ndarrays or cuqi.array.CUQIarray objects) –

    Positional arguments for the values at which to compute the gradient. The gradient operator input can be specified as either positional arguments or keyword arguments but not both.

    If the input is specified as positional arguments, the order of the arguments should match the non_default_args of the model.

  • is_direction_par (bool) – If True, direction is assumed to be parameters. If False, direction is assumed to be function values.

  • is_var_par (bool or a tuple of bools) – If True, the inputs in args or kwargs are assumed to be parameters. If False, the inputs in args or kwargs are assumed to be function values. If is_var_par is a tuple of bools, the inputs in args or kwargs are assumed to be parameters or function values based on the corresponding boolean value in the tuple.