Implementation of Quantum convolution in classical

Hi all! I want to implement Quantum convolution layer into my classical model. I am referring this tutorial (tutorial_quanvolution)to get started.
I am working on a model (Graph neural network) which is used to find the properties of molecule. The steps being followed in model are:

  1. Feature embedding
  2. 3D graph convolution
  3. readout
  4. fully-connected phases
def quanv(image):
    """Convolves the input image with many applications of the same quantum circuit."""
    out = np.zeros((14, 14, 4))

    # Loop over the coordinates of the top-left pixel of 2X2 squares
    for j in range(0, 28, 2):
        for k in range(0, 28, 2):
            # Process a squared 2x2 region of the image with a quantum circuit
            q_results = circuit(
                    image[j, k, 0],
                    image[j, k + 1, 0],
                    image[j + 1, k, 0],
                    image[j + 1, k + 1, 0]
            # Assign expectation values to different channels of the output pixel (j/2, k/2)
            for c in range(4):
                out[j // 2, k // 2, c] = q_results[c]
    return out

I was wondering how do I replace this code snippet and change as per my requirement.

Hello @Nina

Thank you for your question! This tutorial might be helpful for your purposes.



1 Like