If you’re using quantum machine learning to look at classical data and solve machine learning problems, then you need to see how to represent this classical data as a quantum state. When you use a quantum device to solve some machine learning problem, it deals with the quantum state, so this data has to be somehow mapped to a quantum state.

There are many ways to do embedding, but we will only be discussing the following:

- Basis embedding
- Amplitude embedding
- Angle embedding

For **basis embedding**, the data must be in the form of a binary string. The concept of basis embedding is based on the use of a computational basis. A scalar value is approximated to its binary form before being transformed into a quantum state. For example, y=010 represents a 3-qubit quantum state, you can see this in the diagram.

There are real input values in amplitude embedding. For example, data point `y`

has four dimensions (for instance, $y_1=1.2,~y_2 = 2.7,~y_3=1.1 ,~y_4=0.5$). We require two qubits for these four features in `y`

. Normalize this input and then directly encode it into the amplitude of our quantum states.

Take a look below for the general formula:

$\psi(y)\rangle = \sum^n_{j=1}y_j |j\rangle$

**$y_j$** is the jth element of y. We have to square-normalize each element. For example,
$\frac{1}{\sqrt{10.19}}$(1.2,2.7,1.1,0.5) and $|j\rangle$ is the computational basis state.

The final form is:

$\frac{1.2}{\sqrt{10.19}}|00\rangle + \frac{2.7}{\sqrt{10.19}}|01\rangle + \frac{1.1}{\sqrt{10.19}}|10\rangle + \frac{0.5}{\sqrt{10.19}}|11\rangle$

Suppose we have a `y`

data point with two features: `y1`

$= 1.4$ and `y2`

$= 0.7$.
These features will become the angle of your rotation in angle embedding. Each of the features use the two qubits separately.

`y1`

can be encoded on the first qubit as:

$\cos\left(\frac{1.4}{2}\right)|0\rangle - \sin\left(\frac{1.4}{2}\right)|1\rangle$

`y2`

can be encoded on the second qubit as:

$\cos\left(\frac{0.7}{2}\right)|0\rangle - \sin\left(\frac{0.7}{2}\right)|1\rangle$

The rotations can be performed on either $x$, $y$, or $z$ axis of the Bloch sphere.

Copyright ©2024 Educative, Inc. All rights reserved

TRENDING TOPICS