Skip to content

Commit

Permalink
Fix: subthreshold dynamics equation of refractory lif (#842)
Browse files Browse the repository at this point in the history
* Fix: subthreshold dynamics equation of refractory lif

* Fix: RefractoryLIF unit test to test the voltage dynamics
  • Loading branch information
monkin77 authored and epaxon committed Jun 20, 2024
1 parent 700a681 commit 5b0883c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/lava/proc/lif/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,8 @@ def subthr_dynamics(self, activation_in: np.ndarray):
self.u[:] = self.u * (1 - self.du)
self.u[:] += activation_in
non_refractory = self.refractory_period_end < self.time_step
self.v[non_refractory] = (self.v[non_refractory] * (
(1 - self.dv) + self.u[non_refractory])
+ self.bias_mant[non_refractory])
self.v[non_refractory] = self.v[non_refractory] * (1 - self.dv) + (
self.u[non_refractory] + self.bias_mant[non_refractory])

def process_spikes(self, spike_vector: np.ndarray):
self.refractory_period_end[spike_vector] = (self.time_step
Expand Down
7 changes: 4 additions & 3 deletions tests/lava/proc/lif/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,13 @@ def test_float_model(self):
refractory_period = 1

# Two neurons with different biases
# No Input current provided to make the voltage dependent on the bias
lif_refractory = LIFRefractory(shape=(num_neurons,),
u=np.arange(num_neurons),
u=np.zeros(num_neurons),
bias_mant=np.arange(num_neurons) + 1,
bias_exp=np.ones(
(num_neurons,), dtype=float),
vth=4.,
vth=4,
refractory_period=refractory_period)

v_logger = io.sink.Read(buffer=num_steps)
Expand All @@ -856,6 +857,6 @@ def test_float_model(self):

# Voltage is expected to remain at reset level for two time steps
v_expected = np.array([[1, 2, 3, 4, 0, 0, 1, 2],
[2, 0, 0, 2, 0, 0, 2, 0]], dtype=float)
[2, 4, 0, 0, 2, 4, 0, 0]], dtype=float)

assert_almost_equal(v, v_expected)

0 comments on commit 5b0883c

Please sign in to comment.