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

Log partition estimator and derivative #180

Closed zaqqwerty closed 2 years ago

zaqqwerty commented 2 years ago

Adds a default log partition function estimator and derivative estimator.

Part of #140. Estimating the QMHL loss requires estimating the log partition function. Equation C1 in the appendix provides a sample-based approximation to it. Here I implemented this approximation in the base EnergyInference class Estimator was low quality, so this is no longer included; instead, each subclass implements its own log partition forward pass.

More importantly, estimating the derivative of the QMHL loss requires estimating the derivative of the log partition function. Luckily this quantity is more well behaved than the log partition itself: an estimator is provided in equation C2 of the appendix. This is implemented as the default for the EnergyInference class.

Depends on #175