tensorflow / quantum

Hybrid Quantum-Classical Machine Learning in TensorFlow
https://www.tensorflow.org/quantum
Apache License 2.0
1.78k stars 571 forks source link

Help to understand QCNN? #252

Closed ghost closed 4 years ago

ghost commented 4 years ago

Could anyone help to explain how this function works?

def two_qubit_pool(source_qubit, sink_qubit, symbols): """Make a Cirq circuit to do a parameterized 'pooling' operation, which attempts to reduce entanglement down from two qubits to just one."""

https://github.com/tensorflow/quantum/blob/master/docs/tutorials/qcnn.ipynb

 Thanks!
MichaelBroughton commented 4 years ago

This function is to recreate a cirq.Circuit that enacts something similar to the pooling operation used in https://arxiv.org/pdf/1810.03787.pdf . If you want more details than what we give in the tutorial I would recommend giving it a read :)

ghost commented 4 years ago

Thanks @MichaelBroughton ! In that paper, they showed a measurement so two qubits are reduced to one. But in this function, there is no measurement:

def two_qubit_pool(source_qubit, sink_qubit, symbols): """Make a Cirq circuit to do a parameterized 'pooling' operation, which attempts to reduce entanglement down from two qubits to just one.""" pool_circuit = cirq.Circuit() sink_basis_selector = one_qubit_unitary(sink_qubit, symbols[0:3]) source_basis_selector = one_qubit_unitary(source_qubit, symbols[3:6]) pool_circuit.append(sink_basis_selector) pool_circuit.append(source_basis_selector) pool_circuit.append(cirq.CNOT(control=source_qubit, target=sink_qubit)) pool_circuit.append(sink_basis_selector**-1) return pool_circuit

MichaelBroughton commented 4 years ago

Yes, instead of measuring we just discard the unused qubits and don't operate on them anymore (which in this context has the same effect).

ghost commented 4 years ago

Thanks @MichaelBroughton ! Which lines do the job of "discard the unused qubits"? Beacuse of cirq.CNOT(control=source_qubit, target=sink_qubit), the two lines are entangled. How do you discard the unused qubits?

MichaelBroughton commented 4 years ago

This happens in software. You can see later on in the tutorial that as we apply the conv and pool layers we operate on fewer and fewer qubits as the network gets deeper. Finally the fact that we don't measure or continue to operate on those qubits is how they get discarded.

If things are still unclear I would recommend examining the circuits and readout operators we are using in the QCNN tutorial and convincing yourself that these circuits are in fact (mostly) equivalent to what is happening in their paper.

Closing.

ghost commented 4 years ago

Hi @MichaelBroughton, Could you explain this comment: """Make a Cirq circuit to do a parameterized 'pooling' operation, which attempts to reduce entanglement down from two qubits to just one.""" What are the two and what is the one in this comment? Thanks!

ghost commented 4 years ago

Hi @MichaelBroughton, one of the consequences of pooling is to create nonlinear effect. If you do not take any measurement in the process, then I guess you do not have this effect? Thanks!