norse.torch.module.coba_lif module

class norse.torch.module.coba_lif.CobaLIFCell(input_size, hidden_size, p=CobaLIFParameters(tau_syn_exc_inv=tensor(0.2000), tau_syn_inh_inv=tensor(0.2000), c_m_inv=tensor(5.), g_l=tensor(0.2500), e_rev_I=tensor(- 100), e_rev_E=tensor(60), v_rest=tensor(- 20), v_reset=tensor(- 70), v_thresh=tensor(- 10), method='super', alpha=100.0), dt=0.001)[source]

Bases: torch.nn.modules.module.Module

Module that computes a single euler-integration step of a conductance based LIF neuron-model. More specifically it implements one integration step of the following ODE

\[\begin{split}\begin{align*} \dot{v} &= 1/c_{\text{mem}} (g_l (v_{\text{leak}} - v) + g_e (E_{\text{rev_e}} - v) + g_i (E_{\text{rev_i}} - v)) \\ \dot{g_e} &= -1/\tau_{\text{syn}} g_e \\ \dot{g_i} &= -1/\tau_{\text{syn}} g_i \end{align*}\end{split}\]

together with the jump condition

\[z = \Theta(v - v_{\text{th}})\]

and transition equations

\[\begin{split}\begin{align*} v &= (1-z) v + z v_{\text{reset}} \\ g_e &= g_e + \text{relu}(w_{\text{input}}) z_{\text{in}} \\ g_e &= g_e + \text{relu}(w_{\text{rec}}) z_{\text{rec}} \\ g_i &= g_i + \text{relu}(-w_{\text{input}}) z_{\text{in}} \\ g_i &= g_i + \text{relu}(-w_{\text{rec}}) z_{\text{rec}} \\ \end{align*}\end{split}\]

where \(z_{\text{rec}}\) and \(z_{\text{in}}\) are the recurrent and input spikes respectively.

Parameters
  • input_size (int) – Size of the input.

  • hidden_size (int) – Size of the hidden state.

  • p (LIFParameters) – Parameters of the LIF neuron model.

  • dt (float) – Time step to use.

Examples

>>> batch_size = 16
>>> lif = CobaLIFCell(10, 20)
>>> input = torch.randn(batch_size, 10)
>>> output, s0 = lif(input)

Initializes internal Module state, shared by both nn.Module and ScriptModule.

forward(input_tensor, state=None)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Return type

Tuple[Tensor, CobaLIFState]

training: bool