qml.jacobian

jacobian(func, argnum)[source]

Returns the Jacobian as a callable function of vector-valued (functions of) QNodes.

This is a wrapper around the autograd.jacobian function.

Parameters
  • func (function) – a vector-valued Python function or QNode that contains a combination of quantum and classical nodes. The output of the computation must consist of a single NumPy array (if classical) or a tuple of expectation values (if a quantum node)

  • argnum (int or Sequence[int]) – which argument to take the gradient with respect to. If a sequence is given, the Jacobian matrix corresponding to all input elements and all output elements is returned.

Returns

the function that returns the Jacobian of the input function with respect to the arguments in argnum

Return type

function