# norse.torch.module.izhikevich module¶

class norse.torch.module.izhikevich.Izhikevich(spiking_method, **kwargs)[source]

A neuron layer that wraps a IzhikevichCell in time such that the layer keeps track of temporal sequences of spikes. After application, the layer returns a tuple containing

(spikes from all timesteps, state from the last timestep).

Example

>>> data = torch.zeros(10, 5, 2) # 10 timesteps, 5 batches, 2 neurons
>>> l = Izhikevich()
>>> l(data) # Returns tuple of (Tensor(10, 5, 2), IzhikevichState)

Parameters
• p (IzhikevichParameters) – The neuron parameters as a torch Module, which allows the module to configure neuron parameters as optimizable.

• dt (float) – Time step to use in integration. Defaults to 0.001.

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

initial_state(input_tensor)[source]
Return type

IzhikevichState

training: bool
class norse.torch.module.izhikevich.IzhikevichCell(spiking_method, **kwargs)[source]

Module that computes a single Izhikevich neuron-model without recurrence and without time. More specifically it implements one integration step of the following ODE:

\begin{align*} \dot{v} &= 0.04v² + 5v + 140 - u + I \dot{u} &= a(bv - u) \end{align*}

and

$\text{if} v = 30 \text{mV, then} v = c \text{and} u = u + d$
Parameters

spiking_method (IzhikevichSpikingBehavior) – parameters and initial state of the neuron

Example with tonic spiking:
>>> from norse.torch import IzhikevichCell, tonic_spiking
>>> batch_size = 16
>>> cell = IzhikevichCell(tonic_spiking)
>>> input = torch.randn(batch_size, 10)
>>> output, s0 = cell(input)


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

initial_state(input_tensor)[source]
Return type

IzhikevichState

training: bool
class norse.torch.module.izhikevich.IzhikevichRecurrent(input_size, hidden_size, spiking_method, *args, **kwargs)[source]

A neuron layer that wraps a IzhikevichRecurrentCell in time such that the layer keeps track of temporal sequences of spikes. After application, the layer returns a tuple containing

(spikes from all timesteps, state from the last timestep).

Example

>>> data = torch.zeros(10, 5, 2) # 10 timesteps, 5 batches, 2 neurons
>>> l = Izhikevich()
>>> l(data) # Returns tuple of (Tensor(10, 5, 2), IzhikevichState)

Parameters
• p (IzhikevichParameters) – The neuron parameters as a torch Module, which allows the module to configure neuron parameters as optimizable.

• dt (float) – Time step to use in integration. Defaults to 0.001.

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

initial_state(input_tensor)[source]
Return type

IzhikevichRecurrentState

training: bool
class norse.torch.module.izhikevich.IzhikevichRecurrentCell(input_size, hidden_size, spiking_method, **kwargs)[source]

Module that computes a single euler-integration step of an Izhikevich neuron-model with recurrence but without time. More specifically it implements one integration step of the following ODE :

\begin{align*} \dot{v} &= 0.04v² + 5v + 140 - u + I \dot{u} &= a(bv - u) \end{align*}

and

$\text{if} v = 30 \text{mV, then} v = c \text{and} u = u + d$
Example with tonic spiking:
>>> from norse.torch import IzhikevichRecurrentCell, tonic_spiking
>>> batch_size = 16
>>> data = torch.zeros(5, 2) # 5 batches, 2 neurons
>>> l = IzhikevichRecurrentCell(2, 4)
>>> l(data) # Returns tuple of (Tensor(5, 4), IzhikevichState)

Parameters
• input_size (int) – Size of the input. Also known as the number of input features. Defaults to None

• hidden_size (int) – Size of the hidden state. Also known as the number of input features. Defaults to None

• p (IzhikevichParameters) – Parameters of the Izhikevich neuron model.

• input_weights (torch.Tensor) – Weights used for input tensors. Defaults to a random matrix normalized to the number of hidden neurons.

• recurrent_weights (torch.Tensor) – Weights used for input tensors. Defaults to a random matrix normalized to the number of hidden neurons.

• autapses (bool) – Allow self-connections in the recurrence? Defaults to False. Will also remove autapses in custom recurrent weights, if set above.

• dt (float) – Time step to use. Defaults to 0.001.

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

initial_state(input_tensor)[source]
Return type

IzhikevichRecurrentState

training: bool