I'm looking for a way to convert images dataset to quantum dataset format to apply some quantum machine learning algorithms. Is it possible?

I have read about that and I found it is possible by using TensorFlow. So, how can I convert my image dataset or tabular (numeric or categorical) dataset to a quantum dataset? To apply some quantum machine learning algorithms or classical deep learning networks.

Is there a tool or GitHub package or even python code to do that?

  • $\begingroup$ Hi and welcome to Quantum Computing SE. I am afraid that under current state of development you would not be able to work with real-world data. The main issues are missing qRAM, know number of qubits in current QPUs and the fact that the quits are too noisy. $\endgroup$ Oct 29, 2022 at 15:53
  • $\begingroup$ @MartinVesely Thank you ... now everything makes sense. I looked for it and I found some algorithms such as CNN can be used with quantum (namely, QCNN). However, classical algorithms still perform better accuracy, prediction, classification, and detection. Especially in the case of images and this is due to quantum ML algorithms require to downscaling images which hides a lot of details and lowers the feature extractor's performance. $\endgroup$ Oct 29, 2022 at 21:35

2 Answers 2


Not specifically for images, but on a general way, Quantum Embedding is the concept what you are looking for:

"A quantum embedding represents classical data as quantum states in a Hilbert space via a quantum feature map."

Reference here.

The process of converting classical data to quantum states can be done using a few different techniques. For instance, Penny Lane will give you:

  1. Basis Encoding and
  2. Amplitude encoding.

You have a few other options such as Product Encoding, Angle Encoding, etc.

Here is a great article with the theoretical background.

In Qiskit you could use ZZFeatureMap and here is an example of how to do it:

# construct QNN
qc = QuantumCircuit(2)
feature_map = ZZFeatureMap(2)
ansatz = RealAmplitudes(2)
qc.compose(feature_map, inplace=True)
qc.compose(ansatz, inplace=True)

This article has also an easy to understand overview about the techniques mentioned above.


I recommend you read this part of the Qiskit textbook to cover the basics of data encoding. There are examples and codes, too, that can help enhance your understanding. Hope that helps!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.