lava-nc / lava

A Software Framework for Neuromorphic Computing
https://lava-nc.org
Other
529 stars 136 forks source link

Fix the PyLifRefractoryModelFloat class' subthreshold dynamics #841

Closed monkin77 closed 2 weeks ago

monkin77 commented 3 months ago

Describe the bug The PyLifRefractoryModelFloat model does not update the voltage correctly in its sub-threshold dynamics. The current equation is: image instead of: image . Therefore, the voltage of the neurons is updated incorrectly.

To reproduce current behavior Steps to reproduce the behavior:

  1. If you create a RefractoryLIF Process like so:
    # Create LIF1 process
    lif1 = LIFRefractory(shape=(2,),  # There are 2 neurons
            vth=1.0,
            v=0,
            dv=0.1,    # Inverse of decay time-constant for voltage decay
            du=0.2,  # Inverse of decay time-constant for current decay
            bias_mant=0,
            bias_exp=0,
            refractory_period=10,
            name="lif1")

and you try to stimulate this Refractory LIF layer with an input, the voltage will always remain at 0 since the initial voltage is 0 and the equation representing the sub-threshold dynamics is wrong (it multiplies the voltage of the previous timestep by the inverse of the decay time-constant + current). So it's always multiplying by 0.

Expected behavior As it stands, it is expected that the LIFRefractory model does not update the voltage dynamics correctly for the reasons mentioned above. By looking at the screenshot below, we can see that the current dynamics are correct, but the voltage dynamics are not.

Screenshots image

Environment:

Additional context This is observed in the PyLifRefractoryModelFloat class that implements the refractory period behavior in a LIF model neuron running on a CPU.