Patch QNN _expectation_function and add associated test.
Since the expectation and pulled_back_expectation functions expect operators to be 1D, needed to add tiling of operators to the underlying _expectation_function body. Also took the opportunity to add a test: to make sure it works with both reduce == True and reduce == False, as well as testing the gradients.
Note I had to remove the @tf.function decorators, something goes wrong with TFQ when gradients are called on the decorated function. Opened issue #71 to track resolution of this.
Patch QNN
_expectation_function
and add associated test.Since the
expectation
andpulled_back_expectation
functions expectoperators
to be 1D, needed to add tiling of operators to the underlying_expectation_function
body. Also took the opportunity to add a test: to make sure it works with bothreduce == True
andreduce == False
, as well as testing the gradients.Note I had to remove the
@tf.function
decorators, something goes wrong with TFQ when gradients are called on the decorated function. Opened issue #71 to track resolution of this.