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

.. only:: html

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

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

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

.. _sphx_glr_auto_examples_layers_plot_lif.py:


==============================
Leaky Integrate and Fire (LIF)
==============================
The :class:`~sinabs.layers.LIF` layer. This neuron integrates the input and decays its state at every time step.

.. GENERATED FROM PYTHON SOURCE LINES 7-25



.. rst-class:: sphx-glr-horizontal


    *

      .. image-sg:: /auto_examples/layers/images/sphx_glr_plot_lif_001.png
         :alt: LIF neuron dynamics
         :srcset: /auto_examples/layers/images/sphx_glr_plot_lif_001.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /auto_examples/layers/images/sphx_glr_plot_lif_002.png
         :alt: LIF neuron dynamics
         :srcset: /auto_examples/layers/images/sphx_glr_plot_lif_002.png
         :class: sphx-glr-multi-img





.. code-block:: default


    import torch
    from utils import plot_evolution

    import sinabs.layers as sl

    const_current = torch.ones((1, 100, 1)) * 0.03
    single_current = torch.zeros((1, 100, 1))
    single_current[:, 0] = 0.1

    lif_neuron = sl.LIF(tau_mem=40.0, norm_input=False, record_states=True)
    plot_evolution(lif_neuron, const_current)


    # By default, no synaptic dynamics are used. We can enable that by setting tau_syn. Note that instead of a constant current, we now provide input only at the first time step.

    lif_neuron = sl.LIF(tau_mem=40.0, tau_syn=30.0, norm_input=False, record_states=True)
    plot_evolution(lif_neuron, single_current)


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

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


.. _sphx_glr_download_auto_examples_layers_plot_lif.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_lif.py <plot_lif.py>`

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

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


.. only:: html

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

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