Skip to content

Refactor reset mechanisms SpikingNeuron base class and (R)Leaky definitions#426

Open
DoubleGio wants to merge 8 commits into
jeshraghian:masterfrom
DoubleGio:reset-refactor
Open

Refactor reset mechanisms SpikingNeuron base class and (R)Leaky definitions#426
DoubleGio wants to merge 8 commits into
jeshraghian:masterfrom
DoubleGio:reset-refactor

Conversation

@DoubleGio

@DoubleGio DoubleGio commented May 15, 2026

Copy link
Copy Markdown

The reset mechanisms in the Leaky class got broken in version 0.08 where they got refactored a bit.
Both soft and hard reset mechanisms do not function as expected: currently the default soft reset resets to zero, whereas the hard reset resets by subtraction -- see this open issue, or you may see for yourself by running tutorial 3 with the current release of snntorch (0.9.4).
To address this:

  1. Refactored SpikingNeuron parent class to more easily allow for custom reset implementations. Instead of only accepting 'subtract', 'zero', and 'none', custom reset_dict can now be redefined in child classes.
  2. Fixed @reset_mechanism.setter to actually change the reset mechanism when altered. This comes with the introduction of the _set_reset_function() function, to be overwritten in child neuron classes.
  3. Refactored reset mechanisms in Leaky (and RLeaky) for clarity and to function as expected:
  • subtract_beta -> $U[t+1] = \beta U[t] + I[t+1] - \beta R U_{\rm thr}$
  • subtract -> $U[t+1] = \beta U[t] + I[t+1] - R U_{\rm thr}$
  • zero -> $U[t+1] = \beta U[t] + I[t+1] - R (\beta U[t] + I[t+1])$
  • none -> $U[t+1] = \beta U[t] + I[t+1]$

@DoubleGio DoubleGio changed the title Reset refactor (R)Leaky and SpikingNeuron base class Refactor reset mechanisms SpikingNeuron base class and (R)Leaky definitions May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant