I want to encode a 28x28 pixels image into quantum state of 6 qubits. Please help with the code
Hi @VQX!
There are many different approaches to do this.
- Encode each pixel using angle embedding.
In our demo on Quanvolutional Neural Networks you can see an example using the MNIST dataset. Notice how we: Reduce dataset size, normalize pixel values within 0 and 1, add extra dimension for convolution channels, and finally use an embedding layer of local π π¦ rotations (with angles scaled by a factor of π). - Use basis embedding
- Use amplitude embedding
You can find a useful discussion around this in this thread, where you can get a sense of the number of qubits you would need.
You can see other examples in our GANs demo, and our tensor-networks quantum circuits demo. This tensor-networks demo uses a simple bars and stripes dataset that can be very useful for testing your encoding.
I encourage you to look at these materials and build your own code. Itβs best if you start with an easy and small example such as the bars and stripes dataset mentioned before, and then you can extend it to larger images.