
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/surrogate_grad_fns/plot_heaviside.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_examples_surrogate_grad_fns_plot_heaviside.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_surrogate_grad_fns_plot_heaviside.py:


=========
Heaviside
=========
:class:`~sinabs.activation.Heaviside` surrogate gradient.

.. GENERATED FROM PYTHON SOURCE LINES 7-18



.. image-sg:: /auto_examples/surrogate_grad_fns/images/sphx_glr_plot_heaviside_001.png
   :alt: plot heaviside
   :srcset: /auto_examples/surrogate_grad_fns/images/sphx_glr_plot_heaviside_001.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    <matplotlib.legend.Legend object at 0x7fd7c0a48c90>





|

.. code-block:: default


    import matplotlib.pyplot as plt
    import torch

    import sinabs.activation as sina

    x = torch.linspace(-2, 4, 500)
    plt.plot(x, sina.Heaviside(window=0.5)(v_mem=x, spike_threshold=1.0), label="Heaviside")
    plt.xlabel("Neuron membrane potential")
    plt.ylabel("Derivative")
    plt.legend()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.124 seconds)


.. _sphx_glr_download_auto_examples_surrogate_grad_fns_plot_heaviside.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example


    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_heaviside.py <plot_heaviside.py>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_heaviside.ipynb <plot_heaviside.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
