Spiking layers can choose any combination of spike generation, reset mechanism and surrogate gradient function.

Spike Generation#

SingleSpike(*args, **kwargs)

PyTorch-compatible function that returns a single spike per time step.

MultiSpike(*args, **kwargs)

PyTorch-compatible function that returns the number of spikes emitted, given a membrane potential value and in a "threshold subtracting" regime.


Wrapper for MaxSpikeInner that does not require passing max_num_spikes_per_bin when calling apply but only at instantiation.

Reset Mechanisms#


Reset the membrane potential v_mem to a given value after it spiked.


Subtract the spiking threshold from the membrane potential for every neuron that spiked.

Surrogate Gradient Functions#

SingleExponential([grad_width, grad_scale])

Surrogate gradient as defined in Shrestha and Orchard, 2018.

PeriodicExponential([grad_width, grad_scale])

Surrogate gradient as defined in Weidel and Sheik, 2021.


Heaviside surrogate gradient with optional shift.

MultiGaussian([mu, sigma, grad_scale])

Surrogate gradient as defined in Yin et al., 2021.