Single qubit neural quantum circuit for solving Exclusive-OR

The main goal of this work was designing a single qubit neural quantum circuit for performing Exclusive-OR, a concrete example of an operation requiring multiple layers in classical neural networks. The corresponding Qiskit code was tested on both simulators and IBM's “ibmqx2” five-qubit quantum processor. Further analyses along training the proposed neural quantum circuit are currently in progress. • A single qubit neural quantum circuit for performing XOR was tested on IBM Q Experience • XOR is a concrete example of an operation requiring multiple layers in classical neural networks


Introduction
A perceptron [1 , 2] is a mathematical model inspired by neural cells. It accepts n input values "connected" to a single output. Each input channel is characterized by a weight parameter. The output is calculated using the activation function: where y is the output, x the input vector, w the trainable weight vector, and t a threshold trainable parameter.
Although of high interest in both neurosciences and artificial intelligence, the model was proven to be limited to linearly separable functions [2] . Thus, for solving the Exclusive-OR (XOR) function a multi-layer perceptron should be considered instead (the connectionist paradigm).
In the field of Quantum Neural Networks there are various attempts [3 -7] at implementing quantum perceptrons. One important direction is based on the qubit neuron concept ("quron"). Most models are exploiting the nonlinearity of the measurement process for implementing the threshold function. Another direction is based on mimicking the classical Rosenblatt perceptron. As opposed to the classical case, quantum perceptrons are not limited to linearly separable problems.
Hybrid quantum-classical neural networks are described in [8] . The approach is based on implementing hidden layers with parameterized quantum circuits (circuits which rotation angles for each gate are specified by the components of a classical input vector). The measurement statistics of each quantum layer is collected and used as input for the following layer. One could calculate the gradient as the difference between the circuit evaluated at θ + s and θ -s , where θ represents the circuit parameters, and s is a macroscopic shift. Thus, the circuit could be trained using gradient descent methods, such as backpropagation. The detailed method, including PyTorch code examples, is also discussed in Ref. [8] .
The ability of single quantum neuron to compute linearly non-separable functions is directly connected with the basic property of quantum mechanics that a wave function is invariant under application of global phase [3 , 6] . For the same reason and, as opposed to classical neurons, AND and OR operations are non-trivial for single quantum neurons [7] . Thus, in Siomau's model [3] is discussed the possibility of computing XOR with a two-qubits perceptron. In Ref. [9] , it was noticed that XOR can also be performed by a particular single qubit parametrized circuit.

Circuit implementation
A single qubit neural circuit is presented in [8] . It contains a Hadamard followed by a rotation RY( θ ) gate, where θ is a trainable parameter. The output in z-basis is given by the expectation: where p(z i ) represents the probability of measuring the value z i . Starting from this example, a particular parametrized quantum circuit with two rotation gates was considered ( Fig. 1 ): RZ( θ 1 * x 1 + α) , and RX( θ 2 * x 2 + α) , where ( x 1 , x 2 ) is the input vector, ( θ 1 , θ 2 ) are the "dendrites" trainable weights, and α is also a trainable parameter. The Hadamard gate is used for initializing the qubit to the | + > diagonal state, while the angles of the two rotation gates are controlled by the ( x 1 , x 2 ) input vector. The output is obtained by collecting the measurement statistics for calculating the expectation σ ( Eq. (2 )). The corresponding Qiskit code is also presented in Appendix A. The circuit could be trained using gradient descent methods as it was designed following the parametrized quantum circuits principles described in [8] . However, for the XOR problem, one solution could be immediately observed on the Bloch Sphere [10] : θ 1 = θ 2 = π , for α = -π /2 . This case is illustrated, for each input vector, in ( Fig. 2 ).

Testing the circuit
The circuit was implemented on IBM Quantum Composer [11] which provides a user-friendly graphical development environment, and which allows running the generated OpenQASM code on several quantum computers(an example of code is available in Appendix B). For a better understanding, both the "ibmq_qasm_simulator" simulator and the "ibmqx2" five-qubit quantum Table 1 The XOR circuit test results.  Table 2 The XOR circuit test results for input data affected by errors.  Table 1 . The differences between the simulator and quantum computer outputs are due to quantum errors [8] . For evaluating the circuit behavior on input data affected by errors, the attached Qiskit code (see Appendix A) was employed on IBM Quantum Lab. One can notice that, within a reasonable error, the circuit succeeded also to classify noisy data ( Table 2 ).

Conclusion
A particular single qubit parametrized quantum circuit for performing XOR was successfully tested on both simulators and the "ibmqx2" five-qubit quantum processor. Further analyses along training the proposed neural quantum circuit are currently in progress.

Direct submission or co-submission
Co-submissions are papers that have been submitted alongside an original research paper accepted for publication by another Elsevier journal from qiskit.visualization import * from numpy import pi qreg_q = QuantumRegister(1, 'q') creg_c = ClassicalRegister (1,