qml.grad

grad(func, argnum)[source]

Returns the gradient as a callable function of (functions of) QNodes.

This is a wrapper around the autograd.grad functions.

Parameters
  • func (function) – a Python function or QNode that contains a combination of quantum and classical nodes

  • argnum (int or list(int)) – which argument(s) to take the gradient with respect to

Returns

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

Return type

function