# What exactly does it mean to embed classical data into a quantum state?

As the title states.

I am a Machine Learning Engineer with a background in physics & engineering (post-secondary degrees). I am reading the Tensorflow Quantum paper. They say the following within the paper:

One key observation that has led to the application of quantum computers to machine learning is their ability to perform fast linear algebra on a state space that grows exponentially with the number of qubits. These quantum accelerated linear-algebra based techniques for machine learning can be considered the first generation of quantum machine learning (QML) algorithms tackling a wide range of applications in both supervised and unsupervised learning, including principal component analysis, support vector machines, kmeans clustering, and recommendation systems. These algorithms often admit exponentially faster solutions compared to their classical counterparts on certain types of quantum data. This has led to a significant surge of interest in the subject. However, to apply these algorithms to classical data, the data must first be embedded into quantum states, a process whose scalability is under debate.

What is meant by this sentence However, to apply these algorithms to classical data, the data must first be embedded into quantum states?

Are there resources that explain this procedure? Any documentation or links to additional readings would be greatly appreciated as well.

Note: I did look at this previous question for reference. It helped. But if anyone can provide more clarity from a more foundational first principles view (ELI5 almost), I would be appreciative

• the TL;DR is that if you want to do quantum computation, you need to operate on quantum states. If you want to do use a quantum computer to process classical data, you thus need to have your classical data somehow encoded into a quantum state. How exactly you do this depends, but in general it's as simple as pretending that, say, an input 00 correspond to this quantum state, 01 to this other one, etc., and then perform your operations on the quantum states
– glS
Mar 31, 2020 at 10:41

First it is instructive to ask oneself: "how does classical data get into my computer?" In a classical computer, your data is always stored in bits. Because calculations in base 2 are not very straightforward for most people there are abstractions like int types for integers and float types for rational numbers with the associated math operations readily abstracted for the user -- which means that you can easily add, multiply, divide and so on.
But you can still do useful stuff with qubits, and this is because they have additional degrees of freedom! One particular thing is that you can encode an angle (which is a real parameter) bijectively into a single qubit by putting it into the relative phase $$| \theta \rangle = \frac{1}{\sqrt{2}}(|0\rangle + \mathrm{e}^{i\theta} |1\rangle)$$
And this is the heart of embedding data into quantum states. You simply can't do the same thing you would be doing on a classical computer due to a lack of sufficient qubit numbers and therefore you have to get creative and use the degrees of freedom of qubits to get your data into the quantum computer. To learn more about very basic embeddings, you should have a look at this paper. One particular example I want to highlight is the so-called "amplitude embedding" where you map the entries of a vector $$\boldsymbol{x}$$ into the different amplitudes of a quantum state $$| \boldsymbol{x} \rangle \propto \sum_i x_i | i \rangle$$ There is no equals sign because the state needs to be normalized, but for the understanding this is not important. The special thing about this particular embedding is that it embeds a vector with $$d$$ elements into $$\log_2 d$$ qubits which is a nice feature in our world where qubits are expensive!
For 32 bit you only need 5 qubits not 32 qubits. $$2^n=N$$, where $$n$$ stands for number of qubits, and $$N$$ stands for number of bits.