I’m trying to compare the effect of various noise-models and noise-model strengths on the actual value of the gradient. To do so, it appears that I should use the
qml.grad function ( https://pennylane.readthedocs.io/en/user-docs-refactor/code/pennylane.grad.html#pennylane.grad ).
I have two issues:
- The QNode wrapper is around a circuit which needs to be executed repeatedly in a larger non-qnode objective function. Something like
objective = lambda xs : sum([circuit(x) for x in xs]). When I call grad on this, it is still quite happy to run, but this looks like it is outside of the scope of the docs, should this work, or do I need a big refactor?
- I’m not sure what the arguments to the _gradient_function should be, and everything I’ve tried throws an error (which could be closely associated with issue 1.)
The approach to my overall task was to have two devices, one analytic and one noisy, and then pull the true gradient out for some fixed circuit parameters using qml.grad, and comparing that to the distribution of noisy parameters. This circuit can be optimized w.r.t. my objective function using a
qml.Optimizer(), and so the gradient is being correctly computed somewhere, if we struggle too much with
qml.grad is there access to the Optimizers internal gradient function for some set of params? Thanks!