# Superposition in classification

**URL:** <https://discuss.pennylane.ai/t/superposition-in-classification/774>\
**Category:** PennyLane Help\
**Created:** [January 22, 2021, 2:24am UTC](https://discuss.pennylane.ai/t/superposition-in-classification/774 "2021-01-22T02:24:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![therafael](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/therafael/32/396_2.png) [@therafael](https://discuss.pennylane.ai/u/therafael)\
**Post date:** [January 22, 2021, 2:24am UTC](https://discuss.pennylane.ai/t/superposition-in-classification/774/1 "2021-01-22T02:24:30Z")

</div>

Hi, most of the classification approaches are what classical computers can also do. eg. classification of hymenoptera. If I mix two images, how can I identify them at the same time using PennyLane (trying to emulate superposition)? In classical DL, you would have to probably separate them. A better example would be sound (eg. during discussion, two speakers can speak at the same time but with classical DL, preprocessing is done to separate the speakers but how can we identify the two at the same time using qml). I was thinking about creating problems classical approached could not solve easily.  
Summary: How to classify 2 different items at the same time?

---

<div class="post-metadata">

**Author:** ![Maria\_Schuld](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/maria_schuld/32/166_2.png) [@Maria\_Schuld](https://discuss.pennylane.ai/u/Maria_Schuld)\
**Post date:** [January 22, 2021, 8:43am UTC](https://discuss.pennylane.ai/t/superposition-in-classification/774/2 "2021-01-22T08:43:53Z")

</div>

Hey @therafael.

Classification in superposition is an interesting topic, and still very much open!

To prepare a superposition of data, you could simply entangle the circuit embedding x\_1 with an ancilla qubit in state |0\rangle, while entangling the circuit embedding x\_2 with the ancilla in |1\rangle to get |\psi\_{\rm ent}\rangle = \frac{1}{\sqrt{2}}| \phi(x\_1) \rangle | 0 \rangle + \frac{1}{\sqrt{2}}| \phi(x\_1) \rangle | 1 \rangle . For more inputs you’d just need more ancillas.

Or you could do a superposition without an ancilla, which is particularly elegant in basis embedding. For example, the two binary data points 010 and 111 can be represented in superposition as \frac{1}{\sqrt{2}}| 010 \rangle + \frac{1}{\sqrt{2}}|111 \rangle .

Controlling an embedding automatically is a feature that we are working on, but for now you would have to code up the circuit by hand (i.e., just replace every gate in the embedding by a controlled version). You’ll see though that the controls introduce quite an overhead that quickly becomes too costly for near-term devices and simulations…

---

<div class="post-metadata">

**Author:** ![therafael](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/therafael/32/396_2.png) [@therafael](https://discuss.pennylane.ai/u/therafael)\
**Post date:** [January 23, 2021, 7:01pm UTC](https://discuss.pennylane.ai/t/superposition-in-classification/774/3 "2021-01-23T19:01:12Z")

</div>

Thanks @Maria_Schuld, will update if I find anything interesting or have more questions.
