I'm now studying quantum machine learning. While studying papers about quantum machine learning, I have a question about quantum embedding. To my knowledge, some general embedding algorithms, such as basis encoding, phase-encoding, and amplitude encoding, encode classical bits into qubits.

However, in many papers leveraging quantum ML, they mention i) "$\textbf{Encode pixels as angles}$" and ii) encode the qubits with the Encoder with several rotation gates $R_x$,$R_y$,$R_z$ and denote the initial quantum state as $|000..\rangle$, $\textit{i.e.}$, several wires with $|0\rangle$ in the figure.

Assume pixels as classical data; I'm confused that i) refers to basis encoding. If so, why is the initial state $|000..\rangle$ rather than $|xxx..\rangle$, where $x \in [0,1]$? In addition, if the encoder conducts the encoding that I illustrated above, are these QML encodes the classical data twice?

I found the above mention in the paper "[Variational Quantum Pulse Learning]"

+) Edit

To understand my question, I'm studying various quantum ML papers and I find that It seems the Encoder in Quantum ML papers is not about embedding (classical bits to qubits). Many descriptions of the encoder are activated on qubits. If so, are these encoders just a part of variational quantum circuits?


2 Answers 2


this is Catalina from PennyLane.

Encoding and embedding are often used interchangeably when referred to inputting data into a quantum computer. Basically what happens is that you can't just import your data the way you would with a classical computer. You need to add gates to the circuit so that the state is modified, and the parameters for these gates are your data. You may need to pre-process your data though. In the case of a pixel we can imagine it has 3 RGB values in the range [0-255]. However you need to turn that into some value that your gates can accept and that will generate a good spread between the corresponding states generated. One option is to multiply each value by 2pi/255, so you end up with values in the range [0-2pi]. Since you have 3 of these values you can encode/embed them into your circuit as one generalized rotation gate or 3 𝑅𝑥, 𝑅𝑦, 𝑅𝑧 gates.

If you're new to quantum computing I recommend the Xanadu Quantum Codebook to get familiarized with some of the basic concepts. For instance, initializing all of your qubits in the |0⟩ state is the general convention.

If you want to learn more about embedding data into a quantum computer I would recommend this blog post.


The scheme they describe does not refer to basis encoding, and they only perform one kind of embedding that I will describe by way of example. For simplicity, suppose the input $\mathbf{x}$ has length 4, perhaps describing a $2 \times 2$ black and white image, and say the quantum embedding uses a single qubit. Then the paper you link (Fig. 2) describes an embedding that looks something like $$ U(\mathbf{x}) = R_y(x_4) R_x (x_3) R_z(x_2) R_y(x_1), \tag{1} $$

where $x_i$ is the $i$-th element of $\mathbf{x}$. In this example $\mathbf{x}$ could be an integer in the range $[0, 256)$ describing intensity of blackness in the $2 \times 2$ image. This particular embedding scheme encodes four integers as angles of rotation around the Bloch sphere starting from an unitialized register $|0\rangle$. Each element $x_i$ is not a single classical bit, it is described by an 8-bit integer. This is allowed because the angles of rotation gates are parameterized by continuous numbers.

Embedding schemes resembling $(1)$ are sometimes called angle encoding. This differs from basis encoding, which would require $\mathbf{x}$ to be an $n$-bit integer if you are using $n$ qubits for the embedding. In this case, for $\mathbf{x}\in \{0, 1\}^n$ the general formula for basis encoding is

$$ U(\mathbf{x}) = \bigotimes_{i=1}^n R_x(\pi x_i). \tag{2} $$

The $\pi$ factor is important because it restricts the rotation to act on the initial state $|0\rangle$ by either doing nothing (resulting in $|0\rangle$) or a $\pi$-rotation (resulting in $|1\rangle$).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.