I have a color image dataset. To represent these images through quantum circuit, how to send each RGB channels through a single quantum circuit? If I have 4 qubits, how to send these qubits through R-G-B channels?
I know how to do it in grayscale images as it has only single channel. If I have a quantum circuit:
n_qubits=4
q_depth=14
def quantum_circuit(noise, weights):
weights = weights.reshape(q_depth, n_qubits)
for i in range(n_qubits):
qml.RY(noise[i], wires=i)
for i in range(q_depth):
for y in range(n_qubits):
qml.RY(weights[i][y], wires=y)
for y in range(n_qubits - 1):
qml.CZ(wires=[y, y + 1])
return qml.probs(wires=list(range(n_qubits)))
So I need 4 qubits in each three channels passing through the quantum circuit. Also the execution needs to be parallel. Any ideas, how to execute it?
Hi @mass_of_15,
I’m not sure about your code but one way of encoding RGB values onto a quantum circuit is by using qml.Rot(). Notice that it takes 3 angles so if you multiply each RGB value by 2pi/255 then you will be able to encode each RBG value in each pixel into a generalized rotation (Rot).
Please let me know if this is clear!
Hi… can you please verify my this code that whether this code of quantum circuit is good for RGB images? I extended the below code which actually was applied on greyscale images in this Quanvolutional Neural Networks | PennyLane Demos
My code:
Hi @Abu_Bakar, welcome to the Forum!
Unfortunately with the code you shared I’m unable to say whether it will work or not. My suggestion is that you test it for a few small images, and check whether you get any errors or the results that you expect.
Thank you madam for your response… I ran the above code and it is running without the error but as the images are RGB so i wanted to make sure that it is okay because the code was given for greyscale images and i wanted to make sure that extended logic is okay for RGB as well or not.
Hi @Abu_Bakar , it’s great to hear that it works!
Enjoy using PennyLane!