Implementing a Quantum Support Vector Machine on a 4-Qubit Quantum Simulator

Whilst great progress has been made in the field of quantum technologies, a general purpose error-corrected quantum computer with a meaningful number of qubits is far from realisation. It is not yet clear how many logical qubits quantum computers require to outperform classical computers, which are very powerful, but it is thought that QML or quantum simulation may provide the first demonstration of a quantum speedup. The obstacles in engineering a quantum computer include ensuring that the qubits remain coherent for the time taken to implement an algorithm, being able to implement gates with ≈0.1% error rates, such that quantum error correction may be performed, and having the qubit implementation be scalabe, such that it admits efficient multiplicative expansions in system size.

A recent attempt at implementing quantum machine learning using a liquid-state nuclear magnetic resonance (NMR) processor was carried out by Zhaokai Li and others. Their approach focused on solving a simple pattern recognition problem of whether a hand-written number was a 6 or a 9. This kind of task can usually be split into preprocessing, image division, feature extraction and classification. First, an image containing a number of characters will be fed into the computer and transformed to an appropriate input format for the classification algorithm. If necessary, a number of other adjustments can be made at this stage, such as resizing the pixels. Next, the image must be split by character, so each can be categorised separately. The NMR-machine built by Li et al. is only configured to accept inputs which represent single digits, so this step was omitted. Key features of the character are then calculated and stored in a vector. In the case of Li et al., each number was split along the horizontal and vertical axes, such that the pixel number ratio across each division could be ascertained. These ratios (one for the horizontal split and one for the vertical) work well as features, since they are heavily dependent on whether the digit is a 6 or a 9. Finally, the features of the input characters are compared with those from a training set. In this case, the training set was constructed from numbers which had been type-written in standard fonts, allowing the machine to determine which class each input belonged to.


Splitting a character in half, either horizontally or vertically, enables it to be classified in a binary fashion. To identify whether a hand-written input is a 6 or a 9, the proportion of the character’s constituent pixels which lie on one side of the division are compared with correspondent features from a type-written training set.

In order to classify hand-written numbers, Li et al. used a quantum support vector machine, which is simply a more rigorous version of Lloyd’s quantum nearest centroid algorithm.

We define a normal vector, n, as

n = Σm i=1 wixi

where wi is the weight of the training vector xi. The machine then identifies an optimal hyperplane (a subspace of one dimension less than the space in which it resides), satisfying the linear equation

n · x + c = 0

The optimisation procedure consists of maximising the distance 2/|n|2 between the two classes, by solving a linear equation made up of the hyperplane parameters wi and c. Harrow, Hassidim and Lloyd (HLL) solves linear systems of equations exponentially faster than classical algorithms designed to tackle the same problem. Therefore, it is hoped that reformulating the support vector machine in a quantum environment will also result in a speedup.

After perfect classification we find that, if xi corresponds to the number 6,

n·xi + c ≥ 1,

whereas if it corresponds to the number 9,

n·xi + c ≤ −1. 

As a result, it is possible to determine whether a hand-written digit is a 6 or a 9 simply by evaluating where its feature vector resides with respect to the hyperplane.

The experimental results published by Li et al. are presented in the Figure below. We can see that their machine was able to recognise the hand-written characters across all instances. Unfortunately, it has long been established that quantum entanglement is not present in any physical implementation of liquid-state NMR. As such, it is highly likely that the work presented here is only a classical simulation of quantum machine learning.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s