• Tidak ada hasil yang ditemukan

Basis encoding and the quantum perceptron algorithm

Routine 4.3.3: Density matrix exponentiation (in superposition)

10.3 Basis encoding and the quantum perceptron algorithm

The second option I want to explore here is to encode the inputs and outputs into the qubits’ state itself as in the first two cases of Table 10.1. It was mentioned before that despite the extensive spatial resources, basis encoding has the advantage that there is always a quantum routine implementing |xi|0i → |xi|f(x)i, even though more qubits as a computational overhead may be needed. This Section proposes a way of implementing the perceptron activation function in such a way, making use of the quantum phase estimation algorithm. More precisely, one constructs a Hamiltonian fulfilling the eigenvalue equation eiHt|xi= eiwTxt|xiand uses the quantum phase es- timation routine to write the eigenvaluewTxinto basis encoding. The first qubit of the eigenvalue register defines if the eigenvalue is larger or smaller than 0.5 and therefore simulates the re- sult of a step function. Note that a coherent training method is still outstanding for future research.

Consider a state

|x1...xNi|0...0i,

where the second register is an index register for computation and containsτ qubits. The xi are either represented by a qubit each in case of binary inputs, or approximated byτ qubits each in case of continuous features. For the following I consider binary features and outputs, in other words a perceptron model that maps from{0,1}n to{0,1}. Furthermore, consider weights in [−1,1] and a step activation function

ϕ(z) =





1, ifz≥0,

−1, else.

. (10.2)

According to Table 10.1 there are two options to encode the weights: First, as a unitary evolution, and second, in basis encoding in a separate register. I will suggest a quantum routine for the former version first, and then suggest how to implement the latter.

1An interesting question is whether the quantum gradient descent method could be adapted to neural network training.

First, put the index register into a uniform superposition by using Hadamards on each qubit.

leading to 12τ P2τ−1

j=0 |x1, ..., xni|ji. Consider a unitary operatorUw=Un(wn)...U2(w2)U1(w1)U0

that is a sequence of single qubit unitary operatorsUi(wi) acting on the ith qubit of the input register. The single-qubit unitaries have the form

Uk(wk) =

e2πiwk/2n 0 0 e2πiwk/2n

.

U0 adds a global phase of πi, so that the resulting phase of state |x1, ..., xni|ji is given by exp(2πi(2n1 wTx+ 0.5)) = exp(2πiφ).

For phase estimation, we need an oracleO that can perform

|xi|ji−→O Uwj|xi|ji,

forj= 1...2τ. For sufficiently smallτ (which is given here as discussed later), this can always be constructed by applyingU conditioned on the index register. For example, if the last qubit is in 1, applyU once, if the second last qubit is in 1, apply U twice, and if the kth last qubit is in 1 applyU for 2k1times.

Applying the oracle leads to a state

√1 2τ

2τ−1

X

j=0

|x1, ..., xnie2πijφ|ji.

The quantum phase estimation routine (introduced as Routine 3.4.2) applies an inverse quantum Fourier transform, and ifφ ≈ 2jτ and discard the input register, this results in a quantum state

|φithat represents the phase φ in binary fraction encoding. For cases φ 6= 2jτ, it can be shown that in order to obtainφaccurately up tok bits of precision with a success probability of 1−, one has to chooseτ =k+dlog (2 +21)e[68].

As a reminder, the qubits q1, ..., qτ of |φi represent the phase via the relationship φ ≈ q1 1

20 + . . . + qτ 1

2τ. The first qubit therefore decides whether the phase is larger or smaller than 0.5, which translates into a decision of whether wTx is larger or smaller than 0.

Since we are only interested in the value of the first qubit, a precision of onlyτ= 2 lets us obtain a 85% probability of success, while onlyτ= 8 qubits lead to a success probability of 99,9%.

The computational complexity of the quantum perceptron algorithm is comparable to resources for the n multiplications and single IF-operation needed to implement a classical perceptron, which are inO(nτ). However, when we only look at the implementation of the nonlinear function, we require only τ(τ+1)2 + 3τ2 gates [68]. To get the first qubit accurate with probability 1−, one needsτ =dlog (2 +21)e.

With a slight variation, we can assume an additional register|wi = |w11, ..., wδ1, . . . , wN1, ..., wNδ i containing the weights inδ-bit binary fraction representation. To write the normalised net input

|0

|x1 H

|0

|0 ...

|x...n-1 ...

... H

H

Uw

Uw

|xn

2 -2 2 -1

QFT-1

U20w

Figure 10.1: Quantum circuit for the quantum perceptron model.

wTxinto the phase of quantum state|xi|0...0i|wione has to replace the parameterised operator Uw with ˜U = U0Qn

k=1

Qδ m=1Uwk

i,xi where U0 again adds 1/2 and we introduce the controlled two-qubit operatorsUwk

i,xi defined as

Uwk

i,xi=

1 0 0 0

0 1 0 0

0 0 e−2πi2n2k 0 0 0 0 e2n22πik

 .

In words, thekth bitwki of the binary representation ofwicontrols a phase shift of 2k. Note that this implementation restricts the weights to [0,1), but a sign for each parameter can be stored in an additional qubit, and its inverse XOR withxkcan be used to control the sign of the phase shift.

Although this is a mere example of how to implement a perceptron in basis encoding, this algorithm opens up a couple of interesting avenues. For example, one can process training sets in superposition by starting with the statePM

m=1|xmiinstead of |xi, so that the entire procedure gets applied in parallel. The result would be a superposition of outputs. From measurements on the output qubit one could get the accuracy or success rate on an entire dataset, which could be useful for potential coherent training procedures.

The implementation of a step function can also be used as part of the ensemble method proposed in the next chapter. In summary, enhancing neural networks with quantum computing seems far more difficult than for many other methods.

The Quantum ensemble learning algorithm

The results of this chapter have been written up for a manuscript with the title “Quantum parallelism for exponentially large ensemble classifiers” and will be submitted for publication soon.

I was responsible for the idea, development, analysis and write-up of the content.

This last chapter of Part III investigates how quantum parallelism can be used to construct en- sembles of quantum classifiers. Ensemble methods train a number of models in a specific training regime and use their combined decision to improve on each individual classifier. Quantum par- allelism refers to the fact that a functionf(h) can be evaluated in superposition on a quantum device. More precisely, the operation |hi ⊗ |0i → |hi ⊗ |f(h)i on the qubit registers|hi,|0i can be applied to a superposition of the first register, P

h|hi ⊗ |0i → P

h|hi ⊗ |f(h)i. I will use this property in order to evaluate a ‘superposition of quantum models’ in parallel and extract a decision via a single qubit measurement. As a particular case, I will analyse a collective decision procedure where each model is weighed by its accuracy on the dataset. A quantum algorithm for the implementation of a quantum ensemble classifier is given, but the results from this analysis extend to applications with classical ensembles as well.