# How to create a non-linear quantum activation function from pennylane

**URL:** <https://discuss.pennylane.ai/t/how-to-create-a-non-linear-quantum-activation-function-from-pennylane/4282>\
**Category:** PennyLane Help\
**Created:** [March 14, 2024, 3:20pm UTC](https://discuss.pennylane.ai/t/how-to-create-a-non-linear-quantum-activation-function-from-pennylane/4282 "2024-03-14T15:20:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Guo](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/martin_guo/32/2234_2.png) [@Martin\_Guo](https://discuss.pennylane.ai/u/Martin_Guo)\
**Post date:** [March 14, 2024, 3:20pm UTC](https://discuss.pennylane.ai/t/how-to-create-a-non-linear-quantum-activation-function-from-pennylane/4282/1 "2024-03-14T15:20:53Z")

</div>

Any ideas about how to create a non-linear gate or non-linear activation function for a quantum circuit?

---

<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:** [March 14, 2024, 8:56pm UTC](https://discuss.pennylane.ai/t/how-to-create-a-non-linear-quantum-activation-function-from-pennylane/4282/2 "2024-03-14T20:56:43Z")

</div>

Hey @Martin_Guo!

You can just do something like this: (taken from this demo: [Turning quantum nodes into Torch Layers | PennyLane Demos](https://pennylane.ai/qml/demos/tutorial_qnn_module_torch/))

```auto
softmax = torch.nn.Softmax(dim=1)
layers = [qlayer, softmax]
model = torch.nn.Sequential(*layers)

```

What this does is tacks on a softmax activation function to the output of the quantum circuit. Let me know if this is what you had in mind!
