hxtorch.spiking.functional.aelif

Adaptive exponential leaky-integrate and fire neurons

Classes

Bounds(lower, torch.Tensor]] =, upper, …)

Class defining bounds of a finite value range and how to deal with the bounds in simulation. :param lower: The lower bound. :param upper: The upper bound. :param device: The device, the tensors containing the bounds are transfered to. :param hardware_aware: When set to True, the saturation effect is considered in the backward pass of the simulation; Else, the backward function is set to be the identity function and torch.clamp() is used instead of a surrogate. :param surrogate: Callable that implements a surrogate function for the clamp function. Is needed in case of of a hardware aware backpropagation.

Handle(*args, **kwargs)

Factory for classes which are to be used as custom handles for observable data, depending on the specific observables a module deals with.

RandomNoise(std, torch.Tensor]] = None, …)

Class defining gaussian random noise to mock the random noise of the membrane and adaptation state on hardware along the time axis.

RandomNoiseAdd(*args, **kwargs)

Add random noise to a tensor

Unterjubel(*args, **kwargs)

Unterjubel hardware observables to allow correct gradient flow

partial

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

Functions

hxtorch.spiking.functional.aelif.cuba_aelif_integration(input: Union[Tuple[torch.Tensor], torch.Tensor], *, leak: Union[torch.Tensor, float, int], reset: Union[torch.Tensor, float, int], threshold: Union[torch.Tensor, float, int], tau_syn: Union[torch.Tensor, float, int], c_mem: Union[torch.Tensor, float, int], g_l: Union[torch.Tensor, float, int], refractory_time: Union[torch.Tensor, float, int], spike_surrogate: Callable = functools.partial(<function superspike>, alpha=50), exp_slope: Union[torch.Tensor, float, int], exp_threshold: Union[torch.Tensor, float, int], subthreshold_adaptation_strength: Union[torch.Tensor, float, int], spike_triggered_adaptation_increment: Union[torch.Tensor, float, int], tau_adap: Union[torch.Tensor, float, int], hw_data: Optional[hxtorch.spiking.handle.Handle_adaptation_spikes_voltage, None] = None, dt: float = 1e-06, trace_noise_current: Optional[hxtorch.spiking.functional.mock.noise.RandomNoise, None] = None, trace_noise_voltage: Optional[hxtorch.spiking.functional.mock.noise.RandomNoise, None] = None, trace_noise_adaptation: Optional[hxtorch.spiking.functional.mock.noise.RandomNoise, None] = None, cadc_readout_noise_current: Optional[hxtorch.spiking.functional.mock.noise.RandomNoise, None] = None, cadc_readout_noise_voltage: Optional[hxtorch.spiking.functional.mock.noise.RandomNoise, None] = None, cadc_readout_noise_adaptation: Optional[hxtorch.spiking.functional.mock.noise.RandomNoise, None] = None, cadc_readout_bounds_current: Optional[hxtorch.spiking.functional.mock.bounds.Bounds, None] = None, cadc_readout_bounds_voltage: Optional[hxtorch.spiking.functional.mock.bounds.Bounds, None] = None, cadc_readout_bounds_adaptation: Optional[hxtorch.spiking.functional.mock.bounds.Bounds, None] = None, dynamic_range_current: Optional[hxtorch.spiking.functional.mock.bounds.Bounds, None] = None, dynamic_range_voltage: Optional[hxtorch.spiking.functional.mock.bounds.Bounds, None] = None, dynamic_range_adaptation: Optional[hxtorch.spiking.functional.mock.bounds.Bounds, None] = None, leaky: bool = True, fire: bool = True, refractory: bool = False, exponential: bool = False, subthreshold_adaptation: bool = False, spike_triggered_adaptation: bool = False, integration_step_code: str)

Adaptive exponential leaky-integrate and fire neuron integration for realization of AdEx neurons with exponential synapses. Certain terms of the differential equations of the membrane voltage v and the adaptation current w can be disabled or enabled via flags.

If all flags are set, it integrates according to:

i^{t+1} = i^t * (1 - dt / au_{syn}) + x^t v^{t+1} = dt / c_{mem} * (g_l * (v_l - v^t + T * exp((v^t - v_T) / T))

  • i^t - w^t) + v^t

z^{t+1} = 1 if v^{t+1} > params.threshold w^{t+1} = w^t + dt / au_{adap} * (a * (v^{t+1} - v_l) - w^t)

  • b * z^{t+1}

v^{t+1} = params.reset if z^{t+1} == 1

Assumes i^0, v^0 = v_leak, if leak term is enabled, else v^0 = 0 and w^0 = 0. :note: One dt synaptic delay between input and output

Parameters
  • input – torch.Tensor holding ‘graded_spikes’ in shape (batch, time, neurons) or tuple which holds one of such tensors for each input synapse.

  • leak – The leak voltage.

  • reset – The reset voltage.

  • threshold – The threshold voltage.

  • tau_syn – The synaptic time constant.

  • c_mem – The membrane capacitance.

  • g_l – The leak conductance.

  • refractory_time – The refractory time constant.

  • spike_surrogate – Surrogate function for the spike triggering mechanism.

  • exp_slope – The exponential slope.

  • exp_threshold – The exponential threshold.

  • subthreshold_adaptation_strength – The subthreshold adaptation strength.

  • spike_triggered_adaptation_increment – The spike-triggered adaptation increment.

  • tau_adap – The adaptive time constant.

  • hw_data – An optional tuple holding optional hardware observables in the order (spikes, membrane_cadc, membrane_madc).

  • dt – Integration step width.

  • trace_noise_currentRandomNoise object which generates random noise that is added onto the simulation result of the synaptic input current in each time step during simulation in order to mock temporal noise. If set to None, no temporal noise will be applied to the current trace.

  • trace_noise_voltageRandomNoise object which generates random noise that is added onto the simulation result of the membrane voltage increment in each time step during simulation in order to mock temporal noise. If set to None, no temporal noise will be applied to the voltage trace.

  • trace_noise_adaptationRandomNoise object which generates random noise that is added onto the simulation result of the adaptation in each time step during simulation in order to mock temporal noise. If set to None, no temporal noise will be applied to the adaptation trace.

  • cadc_readout_noise_currentRandomNoise object which generates random noise that is added onto the simulation result of the synaptic current once after the simulation in order to mock readout noise. If set to None, no readout noise will be applied to the synaptic current.

  • cadc_readout_noise_voltageRandomNoise object which generates random noise that is added onto the simulation result of the membrane voltage once after the simulation in order to mock readout noise. If set to None, no readout noise will be applied to the membrane voltage.

  • cadc_readout_noise_adaptationRandomNoise object which generates random noise that is added onto the simulation result of the adaptation once after the simulation in order to mock readout noise. If set to None, no readout noise will be applied to the adaptation.

  • cadc_readout_bounds_currentBounds object that specifies lower and upper bounds of the value range the resulting observable data for current is clamped to after the simulation is finished. If set to None, no clamping is performed on the current data after the simulation.

  • cadc_readout_bounds_voltageBounds object that specifies lower and upper bounds of the value range the resulting observable data for voltage is clamped to after the simulation is finished. If set to None, no clamping is performed on the voltage data after the simulation.

  • cadc_readout_bounds_adaptationBounds object that specifies lower and upper bounds of the value range the resulting observable data for adaptation is clamped to after the simulation is finished. If set to None, no clamping is performed on the adaptation data after the simulation.

  • dynamic_range_currentBounds object that specifies lower and upper bounds of the value range for the current trace. If a bound is exceeded in a time step in simulation, the value for the current is clamped to the according bound. If set to None, no clamping is performed on the current trace throughout simulation.

  • dynamic_range_voltageBounds object that specifies lower and upper bounds of the value range for the voltage trace. If a bound is exceeded in a time step in simulation, the value for the voltage is clamped to the according bound. If set to None, no clamping is performed on the voltage trace throughout simulation.

  • dynamic_range_adaptationBounds object that specifies lower and upper bounds of the value range for the adaptation trace. If a bound is exceeded in a time step in simulation, the value for the adaptation is clamped to the according bound. If set to None, no clamping is performed on the adaptation trace throughout simulation.

  • leaky – Flag that enables / disables the leak term when set to true / false

  • fire – Flag that enables / disables firing behaviour when set to true / false.

  • refractory – Flag used to omit the execution of the refractory update in case the refractory time is set to zero.

  • exponential – Flag that enables / disables the exponential term in the differential equation for the membrane potential when set to true / false.

  • subthreshold_adaptation – Flag that enables / disables the subthreshold adaptation term in the differential equation of the adaptation when set to true / false.

  • spike_triggered_adaptation – Flag that enables / disables spike-triggered adaptation when set to true / false.

Returns

Returns tuple holding tensors with spikes, membrane traces, adaptation current and synaptic current. Tensors are of shape (time, batch, neurons).

hxtorch.spiking.functional.aelif.refractory_update(z: torch.Tensor, v: torch.Tensor, ref_state: torch._VariableFunctionsClass.tensor, spikes_hw: torch.Tensor, membrane_hw: torch.Tensor, *, reset: torch.Tensor, refractory_time: torch.Tensor, dt: float)Tuple[torch.Tensor, ]

Update neuron membrane and spikes to account for refractory period. This implemention is widly adopted from: https://github.com/norse/norse/blob/main/norse/torch/functional/lif_refrac.py

Parameters
  • z – The spike tensor at time step t.

  • v – The membrane tensor at time step t.

  • ref_state – The refractory state holding the number of time steps the neurons has to remain in the refractory period.

  • spikes_hw – The hardware spikes corresponding to the current time step. In case this is None, no HW spikes will be injected.

  • membrnae_hw – The hardware CADC traces corresponding to the current time step. In case this is None, no HW CADC values will be injected.

  • reset – The reset voltage as torch.Tensor.

  • refractory_time – The refractory time constant as torch.Tensor.

  • dt – Integration step width.

Returns

Returns a tuple (z, v, ref_state) holding the tensors of time step t.

hxtorch.spiking.functional.aelif.saturate(input: torch.Tensor, bounds: hxtorch.spiking.functional.mock.bounds.Bounds)torch.Tensor

Applies thresholds. :param input: Tensor, to which the thresholds are applied to. :param bounds: Bounds object containing thesholds and the function, which

is used to apply the thresholds.

hxtorch.spiking.functional.aelif.superspike(input: torch.Tensor, alpha: float)torch.Tensor