From this circuit, and from reading Farhi et al., I added the following:
A 5th qubit to be a readout bit (ancilla) to measure the predicted label of the readout bit.
A Pauli-X gate to ensure the readout bit would be |1> following Farhi's paper prior to start measuring the predicted label.
N-bit toffoli gate to indirectly measure the ansatz to measure the effects of the $(\beta, \gamma)$ in the circuit as these are changed.
Hadamard layer before entering the operations shown in the picture above. I did this to be able to apply the optimization algorithm successfully; otherwise, without this first Hadamard layer, it will never converge.
Having a readout bit that can measure the ansatz, and following the QNN paper, one defines:
loss$(\theta,z) = 1 - l( 𝑧 )𝑃(\phi)$,
where $P(\phi)$ is the result of measuring the output of the readout bit as you change $\beta, \gamma$, and $l(z)$ is the label of quantum bit. It turns out that for the purposes of implementation this relation can be stated as:
loss$(\theta,z) \approx 1 - [𝑃(\phi)]^2$,
I have applied this technique to this circuit, and while for some cases the technique performs well, I see some instances this output:
Plot on the left shows the loss function as parameters in circuit are variated; Plot on the right shows the state of readout bit under optimization process. Presumably, since the readout bit after X-gate is converted to |1>, the minimization of the loss measured in this system will return the readout bit to this state. That said, if you find this assumption also questionable, please let me know.
And it can get much worse:
So, here are my questions:
Clearly the loss function shows something is not right with this setup. Granted, the circuit itself can be flawed, I for one I am not sure if acting Pauli-X on the readout bit and then n-toffoli gate was the right thing to do. That said, I am not sure about that after this results. How do you "debug" a circuit with this in mind?
As a general question, given that from this toy-model it is clear that one cannot willy-nilly apply QNN to any random circuit, what is the criteria, if any, Hamiltonian / random quantum circuit, must have to be worth applying this technique.
Are there any better ways to extract information of the circuit for an optimization method than the n-toffoli approached I took? For example, I know it is a silly question, but can you illustrate how useful it can be to apply measurement gates to all the qubits?
Suppose you are shown this picture of the circuit, how can one take the circuit layout and go back to the Hamiltonian for the circuit? I ask because I am both fascinated and a bit confused about how can the Ising, Hubbard-fermi, among many others, are represented by a hamiltonian that can also be expressed as a quantum circuit through an ansatz.
Just for reference, optimization algorithm I implemented is the one discussed on Farhi et al but with the modification of Adam to SGD. On a paper out of Google X last two weeks ago they shown it could successfully be applied for machine learning applications on both quantum circuits but also Tensor Networks.
Sorry for the long post. Thank you for reading, and thanks in advance for your feedback.