qml.gradients.compute_vjp¶
-
compute_vjp
(dy, jac, num=None)[source]¶ Convenience function to compute the vector-Jacobian product for a given vector of gradient outputs and a Jacobian.
- Parameters
dy (tensor_like) – vector of gradient outputs
jac (tensor_like) – Jacobian matrix. For an n-dimensional
dy
vector, the first n-dimensions ofjac
should match the shape ofdy
.num (int) – The length of the flattened
dy
argument. This is an optional argument, but can be useful to provide ifdy
potentially has no shape (for example, due to tracing or just-in-time compilation).
- Returns
the vector-Jacobian product
- Return type
tensor_like
code/api/pennylane.gradients.compute_vjp
Download Python script
Download Notebook
View on GitHub