Entanglement and encoding

Hi,

I was experimenting with hybrid quantum neural networks on an image dataset. I used rather simple hardware efficient quantum circuits with a single parametrize gate (RY) per qubit. First I try quantum circuit with entanglement (CNOT on nearest neighbors) and then I removed CNOTs (no entanglement). The results show that for amplitude encoding, including entanglement yields better accuracy than no entanglement, whereas in case of angle encoding including entanglement degrades the accuracy when compared with the results of circuit containing no entanglement.
Why is this the case, any mathematical reasoning behind it would be helpful.

Thanks

Hi @Muhammad_Kashif!

When you encode your data you want the state of the circuit to be as distinct as possible for different data inputs. For instance, if you’re encoding the colour of a pixel in RGB you want the colour red to be represented differently than the colour blue.

In amplitude embedding the input data will be encoded into the amplitudes of the state, so that embedding may or may not include CNOTs. For angle embedding however it is embedded as only rotations, and if you add other gates in the middle then you may be bringing the resulting states for two distinct inputs too close together.

The results will depend on your specific dataset but this is what my intuition tells me that may be happening.

For illustration purposes, notice how the embedding always goes before the parametrized ansatz. I hope this gives you some insight!

Hi @CatalinaAlbornoz,

Thanks for the answer. However, I think it got confusing as if I was asking about entanglement during the encoding, which i am not. let me just rephrase my query:

So I have this image (greyscale) classification task. For instance, the input feature size is 8, I use pennylane's built-in amplitude and angle embedding to encode features. Now for the ansatz I use two different parameterized quantum circuits.

  1. only contains one single-qubit parameterized unitaries per qubit
  2. contains one single-qubit parameterized unitaries per qubit as well as CNOT on neighboring qubits.

As far as I understand, the encoding part is not trained. So when I encode the data using amplitude embedding the second ansatz (no entanglement) yields better performance (in terms of accuracy), whereas with angle embedding, the second ansatz (with entanglement) achieves better accuracy. This lead to a conclusion that with amplitude embedding including entanglement in quantum ansatz (after the embedding) seems like not useful (infact degrades the performance) than ansatz 1 which contains no entanglement. On the other hand, the inclusion of entanglement does play a positive role when using angle embedding (higher accuracy).

Hope it will now help you better understand my query.

Thanks for the great help.

Hi @Muhammad_Kashif,

Thank you for the clarification! This can depend on the dataset that you’re using. One thing you can do to improve your ansatz is to change the CNOTs for controlled RX gates (CRX). These gates take a parameter theta, so if theta is zero then it will be like not applying the gate, and if theta is pi then it will be like applying a CNOT. This way your program itself can be trained to choose when a CNOT is helpful and when it isn’t.

Please let me know if this solves your problem!

Hi @CatalinaAlbornoz

Thanks for your response and a hint towards ansatz improvement. However, even in this case, my questions would remain the same. Why the entanglement introduction in ansatz seems to have a positive effect on models performance (in terms of accuracy) when the data is encoded qubit amplitudes, whereas for angle encoding the performance is reduced if there is entanglement in ansatz.

Thanks

Hi @Muhammad_Kashif, finding the right ansatz for your problem and dataset is still an open research question. Researchers have found that different ansatze work for different problems, different datasets, and different embeddings. Having entanglement in the ansatz isn’t always helpful and your experience is a demonstration of this. Adding CRX gates is a way of removing part of this issue.

I hope this motivates you to keep looking into the question of ansatz choice. It’s definitely an interesting topic to explore.

I hope this helps!

Hi @CatalinaAlbornoz,

Thanks for the great help.