Demystifying Quantum Machine Learning

Vaibhav Tiwari
9 min readFeb 25, 2020

--

Image Source: discovermagazine.com

Quantum Machine learning is the key to discovering new Elements, drugs, Protein Folding, Material discovery and non-crack able security. To understand Quantum Machine learning, we should first understand Quantum Computing and Machine learning. Let’s demystify the basics of Quantum Computers and what it is: -

Quantum Computer: — A quantum computer is a computer that assimilate aspects of quantum theory. Quantum computers can be called probabilistic or non-deterministic computers. The idea is that quantum computers can use certain phenomena from quantum mechanics, such as superposition and entanglement, to perform operations on data. The basic principle behind quantum computation is that quantum properties can be used to represent data and perform operations on it. A theoretical model is the quantum Turing machine, also known as the universal quantum computer.

Properties of quantum physics that is being utilized by quantum computer are as follows:

Superposition :

Quantum superposition is a fundamental principle of quantum mechanics. It states that, much like waves in classical physics, any two (or more) quantum states can be added together (“superposed”) and the result will be another valid quantum state; and conversely, that every quantum state can be represented as a sum of two or more other distinct states.

Quantum computer with n qubits can be in any superposition of 2^n states simultaneously. For example, the space required if n = 50 qubits a 2^50 complex numbers ~ 18 PB of memory. (1 PB = 1 million GB)

Entanglement :

Quantum entanglement is a label for the observed physical phenomenon that occurs when a pair or group of particles is generated, interact, or share spatial proximity in a way such that the quantum state of each particle of the pair or group cannot be described independently of the state of the others, even when the particles are separated by a large distance. Simply put, when two or more particles are in entangled then measuring the properties of one particle will let you know the properties of other entangled particle.

The above phenomenon helped scientist to build Quantum Computers which are million times faster than our classical computer.

Quantum Computing : Quantum Computing is the use of quantum-mechanical phenomena such as superposition and entanglement to perform computation. A quantum computer is used to perform such computation, which can be implemented theoretically or physically. Currently, there are two main approaches to physically implementing a quantum computer- analog and digital. Analog approaches are further divided into quantum simulation, quantum annealing, and adiabatic quantum computation. Digital quantum computers use quantum logic gates to do computation. Both approaches use quantum bits or qubits.

So what are these Qubits and how is it different than a bit?

Bloch Sphere

Qubit : In quantum computing, a qubit or quantum bit is the basic unit of quantum information the quantum version of the classical binary bit . A qubit can be in two states simultaneously unlike a bit which can only exist in one state at a time i.e. 0 or 1.A pure qubit state is a coherent superposition of the basis states. This means that a single qubit can be described by a linear combination of |0> and |1>:

|Ѱ > = α |0 > + β|1 >

where α and β are probability amplitudes and can in general both be complex numbers. the absolute squares of the amplitudes equate to probabilities, it follows that α and β must be constrained by the equation:

|α |^2 + | β|^2 = 1

What is Machine Learning ?

Our advancement with data science let us developing Machine learning algorithm in order to help machine analyze data and understand patterns.

Machine Learning:

Machine learning is a field of artificial intelligence that seeks patterns in empirical data without forcing models on the data that is, the approach is data-driven, rather than model-driven. A typical example is clustering: given a distance function between data instances, the task is to group similar items together using an iterative algorithm. Another instance is fitting a multidimensional function on a set of data points to estimate the generating distribution.

The advantage of algorithmic learning theory is that it does not make use of statistical assumptions. Hence, we have more freedom in analyzing complex real-life data sets, where samples are dependent, where there is excess noise, and where the distribution is entirely unknown or skewed. Irrespective of the approach taken, machine learning algorithms fall into two major categories: -

1. Supervised learning: The learning algorithm uses samples that are labeled. For example, the samples are micro array data from cells, and the labels indicate whether the sample cells are cancerous or healthy. The algorithm takes these labeled samples and uses them to induce a classifier. This classifier is a function that assigns labels to samples, including those that have never previously been seen by the algorithm.

2. Unsupervised learning: In this scenario, the task is to find structure in the samples. For instance, finding clusters of similar instances in a growing collection of text documents reveals topical changes across time, highlighting trends of discussions, and indicating themes that are dropping out of fashion.

Relation between ML & QML:

Plenty of Use cases cannot be solved with Machine learning running on classical Computers due to the size of the data and computational limit of the system. One such example is how Netflix takes 1 day to do PCA (Principal Component Analysis). They do PCA every day because it takes a whole day to compute the results and provide relevant suggestions to the users based on their previous likes and watch history. The same problem can be solved with quantum computer in minutes.

Source: gputechconf.com

To understand better, the computational Capability of Quantum Computers giving comparisons between Classical & Quantum computers solving the same mathematical problem.

Computational Capability of Quantum Machine

What is Quantum machine Learning (QML)?

Many quantum learning algorithms rely on the application of Grover’s search or one of its variants. This includes mostly unsupervised methods: K-medians, hierarchical clustering, or quantum manifold embedding. In addition, quantum associative memory and quantum neural networks often rely on this search. An early version of quantum support vector machines also uses Grover’s search.

Grover’s search has a quadratic speedup over the best possible classical algorithm on unordered data sets. This sets the limit to how fast those learning methods will train that rely on it. Exponential speedup is possible in scenarios where both the input and the output are also quantum: listing class membership or reading the classical data once would imply at least linear time complexity, which could only be a polynomial speedup. Examples include quantum principal component analysis, quantum K-means, and a different flavor of quantum support vector machines. Regression based on quantum process tomography requires an optimal input state, and, in this regard, it needs a quantum input.

From Quantum Machine Learning by Peter Wittek

Quantum Machine Learning:

Data preparation and pre-processing:

Classically, data sets are typically presented as arrays of symbols and numbers. We assume that our data sets that consist of arrays of numbers (vectors), and arrays of arrays (collections of vectors), originally stored in random access memory (RAM) in the classical case, or in quantum random access memory (qRAM) in the quantum case. The key feature of quantum machine learning is that quantum random access memory allows us to access the data in quantum parallel.

qRAM : In comparison to the normal RAM, qRAM is ultrafast and very small in size ,the address location can be access using qubits superposition value, for a very large memory set coherent superposition(address of address) can be used.

Unsupervised quantum learning:

The exponential quantum speed-up explained above holds for supervised learning. A similar speed-up extends to unsupervised learning. Consider the k-means problem of assigning M vectors to k clusters in a way that minimizes the average distance to the centroid of the cluster.

The standard method for solving k-means is Lloyd’s algorithm choose the initial centroid randomly or by a method such as k-means++;

1. Assign each vector to the cluster with the closest mean.

2. Recalculate the centroids of the clusters;

3. Repeat steps (1–2) until a stationary assignment is attained.

4. When classical estimation of the distance to the centroids in the N-dimensional space takes time O(N), each step of the classical algorithm takes time O(M2N), while the quantum Lloyd’s algorithm takes time O(M log(MN)).

5. The additional factor of M in both classical and quantum algorithms arises because every vector is tested individually for reassignment at each step

Sharing a Project for Quantum Machine learning for Breast Cancer Cell detection:

The Problem focused here is to determine if cells are Cancerous or not for a specific Breast Cancer dataset. Support Vector machine quantum algorithm is used to predict the accuracy and determine how well the model works for classifying the dataset.

How it’s done:

Preparing the breast cancer dataset for the Quantum Circuit and importing to run on algorithm.

1. Import dataset from sklearn or via this website.

2. Defining the variables to include Training datasets, testing and how it’s split.

3. Normalizing to 0 variance such that pixels from image have small range and become easy to compute.

4. Using IBM’s qiskit library for transforming datasets into number of qubits.

5. Set the range for SVM to -1 to +1 so classification can be done based on data point lying on the range.

6. Set up training Dataset.

7. Set up a plot to showcase visually the classification.

Implementing the QML algorithm:

IBM has it’s library which can easily simulate by doing these:

1. Declaring number of Qubits for your Quantum Circuit.

2. Defining the classes and importing the dataset which we manipulated above.

3. Dictating the algorithm & setting parameters for how many iteration it should do and depth of the circuit.

4. Input the new datapoints.

5. Check the results after the algorithm is finished running.

Classification of Cancerous Cell

The data classification is shown in the image above and the different color is representing whether a data point classifies as cancerous or not. The results shows that quantum computers are able to produce similar results to a classical computer.

Git Hub link for the QML project :

https://github.com/v41bh4v/Quantum-Machine-Learning

Conclusion:-

To recapitulate, burgeoning technology and advancement in building hardware we will be able to run complex algorithms. The field of QML will be massive with immense amount of applications. An example of such applications can be seen with Volkswagen.

Volkswagen experts have developed a program on a quantum computer that precisely predicts future traffic volumes, demand for transport and the duration of each journey. This helps to avoid traffic jams and shorten waiting times. Denso is on the Track of implementing Quantum Technology to analyze Big Data.

My goal is to continue the journey of learning and sharing about Quantum Machine Learning and prepare for the time when we will have stable hardware to run big complex algorithm for drug discovery, material discovery , protein folding and discovering new secrets about our Universe.

Thank you for reading, stay connected if you would like to see more blogs on Quantum computing…..

References:

1. Seth Lloyd1,3 , Masoud Mohseni2 , Patrick Rebentrost1 https://arxiv.org/pdf/1307.0411.pdf

2. Quantum Machine Learning Wikipedia: https://en.wikipedia.org/wiki/Quantum_machine_learning

3. Qiskit by IBM: https://github.com/Qiskit/qiskit

--

--

Vaibhav Tiwari

Research Scientist Quantum Computing, Head of Makers Lab japan