norse.torch.functional.lif_ex module¶
- class norse.torch.functional.lif_ex.LIFExFeedForwardState(v: torch.Tensor, i: torch.Tensor)[source]¶
Bases:
tuple
State of a feed forward LIFEx neuron
- Parameters
v (torch.Tensor) – membrane potential
i (torch.Tensor) – synaptic input current
Create new instance of LIFExFeedForwardState(v, i)
- i: torch.Tensor¶
Alias for field number 1
- v: torch.Tensor¶
Alias for field number 0
- class norse.torch.functional.lif_ex.LIFExParameters(delta_T: torch.Tensor = tensor(0.5000), tau_syn_inv: torch.Tensor = tensor(200.), tau_mem_inv: torch.Tensor = tensor(100.), v_leak: torch.Tensor = tensor(0.), v_th: torch.Tensor = tensor(1.), v_reset: torch.Tensor = tensor(0.), method: str = 'super', alpha: float = 100.0)[source]¶
Bases:
tuple
Parametrization of an Exponential Leaky Integrate and Fire neuron
- Parameters
delta_T (torch.Tensor) – sharpness or speed of the exponential growth in mV
tau_syn_inv (torch.Tensor) – inverse synaptic time constant (\(1/\tau_\text{syn}\)) in 1/ms
tau_mem_inv (torch.Tensor) – inverse membrane time constant (\(1/\tau_\text{mem}\)) in 1/ms
v_leak (torch.Tensor) – leak potential in mV
v_th (torch.Tensor) – threshold potential in mV
v_reset (torch.Tensor) – reset potential in mV
method (str) – method to determine the spike threshold (relevant for surrogate gradients)
alpha (float) – hyper parameter to use in surrogate gradient computation
Create new instance of LIFExParameters(delta_T, tau_syn_inv, tau_mem_inv, v_leak, v_th, v_reset, method, alpha)
- delta_T: torch.Tensor¶
Alias for field number 0
- tau_mem_inv: torch.Tensor¶
Alias for field number 2
- tau_syn_inv: torch.Tensor¶
Alias for field number 1
- v_leak: torch.Tensor¶
Alias for field number 3
- v_reset: torch.Tensor¶
Alias for field number 5
- v_th: torch.Tensor¶
Alias for field number 4
- class norse.torch.functional.lif_ex.LIFExState(z: torch.Tensor, v: torch.Tensor, i: torch.Tensor)[source]¶
Bases:
tuple
State of a LIFEx neuron
- Parameters
z (torch.Tensor) – recurrent spikes
v (torch.Tensor) – membrane potential
i (torch.Tensor) – synaptic input current
Create new instance of LIFExState(z, v, i)
- i: torch.Tensor¶
Alias for field number 2
- v: torch.Tensor¶
Alias for field number 1
- z: torch.Tensor¶
Alias for field number 0
- norse.torch.functional.lif_ex.lif_ex_current_encoder(input_current, voltage, p=LIFExParameters(delta_T=tensor(0.5000), tau_syn_inv=tensor(200.), tau_mem_inv=tensor(100.), v_leak=tensor(0.), v_th=tensor(1.), v_reset=tensor(0.), method='super', alpha=100.0), dt=0.001)[source]¶
Computes a single euler-integration step of a leaky integrator adapted from https://neuronaldynamics.epfl.ch/online/Ch5.S2.html. More specifically it implements one integration step of the following ODE
\[\begin{split}\begin{align*} \dot{v} &= 1/\tau_{\text{mem}} \left(v_{\text{leak}} - v + i + \Delta_T exp\left({{v - v_{\text{th}}} \over {\Delta_T}}\right)\right) \\ \dot{i} &= -1/\tau_{\text{syn}} i \end{align*}\end{split}\]- Parameters
input (torch.Tensor) – the input current at the current time step
voltage (torch.Tensor) – current state of the LIFEx neuron
p (LIFExParameters) – parameters of a leaky integrate and fire neuron
dt (float) – Integration timestep to use
- Return type
- norse.torch.functional.lif_ex.lif_ex_feed_forward_step(input_tensor, state=LIFExFeedForwardState(v=0, i=0), p=LIFExParameters(delta_T=tensor(0.5000), tau_syn_inv=tensor(200.), tau_mem_inv=tensor(100.), v_leak=tensor(0.), v_th=tensor(1.), v_reset=tensor(0.), method='super', alpha=100.0), dt=0.001)[source]¶
Computes a single euler-integration step of an exponential LIF neuron-model adapted from https://neuronaldynamics.epfl.ch/online/Ch5.S2.html. It takes as input the input current as generated by an arbitrary torch module or function. More specifically it implements one integration step of the following ODE
\[\begin{split}\begin{align*} \dot{v} &= 1/\tau_{\text{mem}} \left(v_{\text{leak}} - v + i + \Delta_T exp\left({{v - v_{\text{th}}} \over {\Delta_T}}\right)\right) \\ \dot{i} &= -1/\tau_{\text{syn}} 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}} \\ i &= i + i_{\text{in}} \end{align*}\end{split}\]where \(i_{\text{in}}\) is meant to be the result of applying an arbitrary pytorch module (such as a convolution) to input spikes.
- Parameters
input_tensor (torch.Tensor) – the input spikes at the current time step
state (LIFExFeedForwardState) – current state of the LIF neuron
p (LIFExParameters) – parameters of a leaky integrate and fire neuron
dt (float) – Integration timestep to use
- Return type
- norse.torch.functional.lif_ex.lif_ex_step(input_tensor, state, input_weights, recurrent_weights, p=LIFExParameters(delta_T=tensor(0.5000), tau_syn_inv=tensor(200.), tau_mem_inv=tensor(100.), v_leak=tensor(0.), v_th=tensor(1.), v_reset=tensor(0.), method='super', alpha=100.0), dt=0.001)[source]¶
Computes a single euler-integration step of an exponential LIF neuron-model adapted from https://neuronaldynamics.epfl.ch/online/Ch5.S2.html. More specifically it implements one integration step of the following ODE
\[\begin{split}\begin{align*} \dot{v} &= 1/\tau_{\text{mem}} \left(v_{\text{leak}} - v + i + \Delta_T exp\left({{v - v_{\text{th}}} \over {\Delta_T}}\right)\right) \\ \dot{i} &= -1/\tau_{\text{syn}} 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}} \\ i &= i + w_{\text{input}} z_{\text{in}} \\ i &= i + 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_tensor (torch.Tensor) – the input spikes at the current time step
s (LIFExState) – current state of the LIF neuron
input_weights (torch.Tensor) – synaptic weights for incoming spikes
recurrent_weights (torch.Tensor) – synaptic weights for recurrent spikes
p (LIFExParameters) – parameters of a leaky integrate and fire neuron
dt (float) – Integration timestep to use
- Return type