Gradient of fidelity with respect to the parameters in circuit
yuyuexi opened this issue · comments
Hi, I am checking the sample code for QCBM and I find it is very efficient for dL/da, where L is the loss and a is the parameters in circuit. This is for the case that the probability of data is the probability of the result state in the computational basis.
However, in general, I think that the probability of data can be the the probability of the result state in others basis, e.g. p(x)=||<x|U|0>||^2, where x is not the computational basis. I am wondering how to compute the gradient of this probability with respect to the parameters in circuit.
- I think using the |x><x| as an observable and then using
expect'
is helpful, but this seems a little ugly. - I notice the
apply_back
can be used to compute the gradient with the \phi being the intermediate variables but cannot figure out how to use it in my problems.
Is there any function I did not noticed yet can help me solve this?
Sorry, I find that the key problem is AD a function with "mutating arrays", which can be solved using a patch code.