quantumcomputingbook icon indicating copy to clipboard operation
quantumcomputingbook copied to clipboard

qnn.py update for most recent versions of Cirq (v0.11+)

Open qlero opened this issue 3 years ago • 0 comments

Hello,

As discussed in issues, here is a pull request with a small update on chapter 9's qnn.py script. The following changes have been made:

  1. (add-on compared to opened issue) Removal of TwoQubitGate from the inheritance arguments of class ZXGate (lines 10-11) as it will be deprecated with cirq v0.14 onward. This is replaced with overriding the function _num_qubits_ in the body of the class such that:
def _num_qubits_(self):
        return 2
  1. Addition of the recursive:bool argument to the override of the function _resolve_parameters_ (line 36) in the body of custom class ZXGate so as to work with cirq versions v0.11 and further.
  2. Replacement of wf = result.final_state with wf = result.final_state_vector (line 79) in the body of function readout_expectation.

Best regards,

Quentin

qlero avatar Mar 19 '22 22:03 qlero