# Implementation of Quantum convolution in classical

**URL:** <https://discuss.pennylane.ai/t/implementation-of-quantum-convolution-in-classical/2555>\
**Category:** PennyLane Development\
**Created:** [February 15, 2023, 5:05am UTC](https://discuss.pennylane.ai/t/implementation-of-quantum-convolution-in-classical/2555 "2023-02-15T05:05:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nina](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@Nina](https://discuss.pennylane.ai/u/Nina)\
**Post date:** [February 15, 2023, 5:05am UTC](https://discuss.pennylane.ai/t/implementation-of-quantum-convolution-in-classical/2555/1 "2023-02-15T05:05:57Z")

</div>

Hi all! I want to implement Quantum convolution layer into my classical model. I am referring this tutorial ([tutorial\_quanvolution](https://pennylane.ai/qml/demos/tutorial_quanvolution.html))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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Alvaro\_Ballon](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/alvaro_ballon/32/874_2.png) [@Alvaro\_Ballon](https://discuss.pennylane.ai/u/Alvaro_Ballon)\
**Post date:** [February 15, 2023, 9:09pm UTC](https://discuss.pennylane.ai/t/implementation-of-quantum-convolution-in-classical/2555/2 "2023-02-15T21:09:44Z")

</div>

Hello @Nina

Thank you for your question! [This tutorial](https://pennylane.ai/qml/demos/tutorial_qgrnn.html) might be helpful for your purposes.

Cheers,

Alvaro
