# Quantum Convolutional Neural Network implementation

**URL:** <https://discuss.pennylane.ai/t/quantum-convolutional-neural-network-implementation/1734>\
**Category:** PennyLane Help\
**Created:** [March 17, 2022, 1:59pm UTC](https://discuss.pennylane.ai/t/quantum-convolutional-neural-network-implementation/1734 "2022-03-17T13:59:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karolishp](https://avatars.discourse-cdn.com/v4/letter/k/da6949/32.png) [@karolishp](https://discuss.pennylane.ai/u/karolishp)\
**Post date:** [March 17, 2022, 1:59pm UTC](https://discuss.pennylane.ai/t/quantum-convolutional-neural-network-implementation/1734/1 "2022-03-17T13:59:06Z")

</div>

Hi, I’m trying to implement [QCNN](https://arxiv.org/pdf/1810.03787.pdf) in Pennylane and ran into a problem.

Given a circuit with _n_ qubits, QCNN requires us to measure _n_/2 of the wires at first pooling layer, _n_/4 wires at second pooling layer and so on. The output of these measurements are used as parameters in rotation gates applied to the _n_/2 remaining wires after first pooling layer, _n_/4 remaining wires after the second pooling layer etc.

Now suppose we have 4 qubits. I tried to perform a measurement on the 0th and 2nd qubits, and then add RY gates to the 1st and 3rd qubits. Unfortunately, I got the error:

> ValueError: Quantum operation RY(tensor(0.95956891, requires\_grad=True), wires=[1]) must occur prior to any measurements.

Given this discussion ([Ancillary Subsystem Measurement then Trace Out](http://discuss.pennylane.ai/t/ancillary-subsystem-measurement-then-trace-out/1532)) a few months ago and my findings, it appears that such operation is not supported, therefore QCNN is impossible to be implemented in Pennylane. Am I correct? Are there any plans to add support for mid-circuit measurement in the near future?

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [March 17, 2022, 11:54pm UTC](https://discuss.pennylane.ai/t/quantum-convolutional-neural-network-implementation/1734/2 "2022-03-17T23:54:49Z")

</div>

Hi @karolishp, mid-circuit measurements were just added to PennyLane in the latest release! 😃

Be sure to upgrade to version 0.22 in order to use this feature. You can learn more about how to use these measurements on our [release blog post](https://pennylane.ai/blog/2022/03/pennylane-v022-released/#quantum-teleport-with-mid-circuit-measurements).

Let me know if you have any further questions!
