google / qhbm-library

Quantum Hamiltonian-Based Models built on TensorFlow Quantum
https://qhbm-library.readthedocs.io/en/latest/
Apache License 2.0
40 stars 15 forks source link

VQT #163

Closed zaqqwerty closed 2 years ago

zaqqwerty commented 2 years ago

Adds VQT loss.

This implementation takes advantage of the new EnergyInference.expectation method, to simplify the structure. See appendix B of the updated paper for the derivation. Part of #139

zaqqwerty commented 2 years ago

Added some new tests confirming that VQT accepts Hamiltonian as an input, and that derivatives can be taken with respect to both the model and the target hamiltonian.

Related to #71, I found that adding persistent=True to the gradient tape on line 144 of vqt_loss_test.py causes the error LookupError: No gradient defined for operation'TfqAdjointGradient' to happen. Can just leave it out, so seems we won't have to deal with https://github.com/tensorflow/quantum/issues/667 quite yet.