# Recommended noise model for QNN?

**URL:** <https://discuss.pennylane.ai/t/recommended-noise-model-for-qnn/3158>\
**Category:** PennyLane Help\
**Created:** [July 8, 2023, 12:34am UTC](https://discuss.pennylane.ai/t/recommended-noise-model-for-qnn/3158 "2023-07-08T00:34:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![schance995](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@schance995](https://discuss.pennylane.ai/u/schance995)\
**Post date:** [July 8, 2023, 12:34am UTC](https://discuss.pennylane.ai/t/recommended-noise-model-for-qnn/3158/1 "2023-07-08T00:34:57Z")

</div>

I’d like to add a noise model to a [quantum transfer neural network](https://pennylane.ai/qml/demos/tutorial_quantum_transfer_learning.html) in Pennylane.

I read the [noisy circuit tutorial](https://pennylane.ai/qml/demos/tutorial_noisy_circuits) but I’m unsure of what noise model to use.

Are there any recommendations? Is there a generic noise model for simulating a generic noisy quantum computer?

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [July 10, 2023, 1:39pm UTC](https://discuss.pennylane.ai/t/recommended-noise-model-for-qnn/3158/2 "2023-07-10T13:39:02Z")

</div>

Hey @schance995! Welcome to the forum 💪

I’d say that [depolarizing noise](https://docs.pennylane.ai/en/stable/code/api/pennylane.DepolarizingChannel.html) is a safe bet for a good “generic” / “common” type of noise. That said, you can get pretty crazy and combine all sorts of different error channels / noise as follows:

```auto
import pennylane as qml

dev = qml.device("default.mixed", wires=2)

@qml.qnode(dev)
@qml.transforms.insert(qml.AmplitudeDamping, 0.1, position="all")
@qml.transforms.insert(qml.DepolarizingChannel, 0.2, position="all")
def f(w, x, y, z):
    qml.RX(w, wires=0)
    qml.RY(x, wires=1)
    qml.CNOT(wires=[0, 1])
    qml.RY(y, wires=0)
    qml.RX(z, wires=1)
    return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))

print(qml.draw(f)(0.9, 0.4, 0.5, 0.6))

```

```auto
0: ──RX(0.90)──AmplitudeDamping(0.10)──DepolarizingChannel(0.20)──AmplitudeDamping(0.10)─╭●
1: ──RY(0.40)──AmplitudeDamping(0.10)──DepolarizingChannel(0.20)──AmplitudeDamping(0.10)─╰X

───AmplitudeDamping(0.10)──DepolarizingChannel(0.20)──AmplitudeDamping(0.10)──RY(0.50)
───AmplitudeDamping(0.10)──DepolarizingChannel(0.20)──AmplitudeDamping(0.10)──RX(0.60)

───AmplitudeDamping(0.10)──DepolarizingChannel(0.20)──AmplitudeDamping(0.10)─┤ ╭<Z@Z>
───AmplitudeDamping(0.10)──DepolarizingChannel(0.20)──AmplitudeDamping(0.10)─┤ ╰<Z@Z>

```

I took the example in the documentation for [qml.transforms.insert](https://docs.pennylane.ai/en/stable/code/api/pennylane.transforms.insert.html?highlight=qml.transforms.insert) and just added another decorator that wraps the circuit in more noise!

Let me know if this helps 😁

---

<div class="post-metadata">

**Author:** ![schance995](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@schance995](https://discuss.pennylane.ai/u/schance995)\
**Post date:** [July 10, 2023, 8:09pm UTC](https://discuss.pennylane.ai/t/recommended-noise-model-for-qnn/3158/3 "2023-07-10T20:09:08Z")

</div>

Thanks @isaacdevlugt , I will look into depolarizing noise further!

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [July 10, 2023, 9:10pm UTC](https://discuss.pennylane.ai/t/recommended-noise-model-for-qnn/3158/4 "2023-07-10T21:10:41Z")

</div>

Awesome! Do respond back if you have any other questions 🙂
