# Normalize and encode real data in a way that encode collinear vectors with different values

Now, I am working on a quantum supervised learning problem and I have a problem with amplitude encoding.

Before being encoded, a vector $$(a_1, a_2,\dots,a_n)$$ must be normalized in such a way that $$\sum_i |a_i|^2 = 1$$

Thereby, the two following vectors would be encoded in the same way : $$(1, 2, 3, 4)$$ and $$(2, 4, 6, 8)$$ normalized as $$(0.18, 0.36, 0.54, 0.73)$$ :

$$0.18\lvert 00\rangle + 0.36\lvert 01\rangle + 0.54\lvert 10\rangle + 0.73\lvert 11\rangle$$.

But in the case of a classification/regression problem I could have a different target for this two vectors and my circuit would not be able to treat them differently.

Is there a way to normalize/encode vectors differently to keep a difference between colinear vectors ?

[Edit :] the final goal is to make a regression model based on a variational circuit as explained on this website but for a different problem : http://docs.qulacs.org/en/latest/apply/5.2_qcl.html

• Is every vector possible, or do you work with only a subset of possible vectors (like only positive ones for instance)? – Tristan Nemoz Jun 3 at 9:10
• The values of the input vector are real values (positive or negative) – Thomas Mullor Jun 3 at 9:15

I'm not sure such a one-to-one function exists. However, it is quite easy to do if you allow yourself to use more than $$\log_2(n)$$ qubits. You can add a register which, up to a given precision, holds the value of the norm of a given vector.

For instance, let us consider the vectors $$\begin{pmatrix}1\\2\\3\\4\end{pmatrix}$$ and $$\begin{pmatrix}2\\4\\6\\8\end{pmatrix}$$. Both are spanned by the unitary vector $$\frac{1}{\sqrt{30}}\begin{pmatrix}1\\2\\3\\4\end{pmatrix}$$. Hence, you can use the first register to represent this unitary vector. The second register would store $$\sqrt{30}$$ for the first vector and $$2\,\sqrt{30}$$ for the second. Note that even though it may be less convenient to store the norm instead of its square, it allows you to use less qubits, since you have to encode smaller numbers.

While this is difficult to tell without knowing what you want to perform, note that this however may requires you to add another step when comparing two vectors.

If this transformation doesn't suit you, please tell me and I'll be happy to delete my answer.

As the previous answer mentions, the right way to approach this depends on what kind of algorithm you are going to run on the amplitude encoded vectors.

One possibility: If you're trying to classify these vectors using a linear classifier, chances are that there is some configuration of the classifier that is translation invariant. This means the problem remains equally solvable if you are trying to discriminate $$x_1$$ versus $$x_2$$ or $$x_1 + v=x_1'$$ versus $$x_2 + v=x_2'$$ (whatever hyperplane solved the first problem just gets shifted by $$v$$!). Then a prescription would be to shift all of your data by some $$v$$ that does not lie in $$\text{span}\{x_1, x_2\}$$, which would result in $$\langle x_1' | x_2'\rangle\neq 1$$. By straightforward geometrical arguments there is even a $$v$$ such that $$\langle x_1' | x_2'\rangle = 0$$ if that better suits your purposes.

• I edited my post, the goal is to make a regression model based on a parameterized quantum circuit. – Thomas Mullor Jun 4 at 8:35