hxtorch.spiking.functional.step_integration_code_factory.CuBaStepCode

class hxtorch.spiking.functional.step_integration_code_factory.CuBaStepCode(leaky: bool = True, fire: bool = True, refractory: bool = False, exponential: bool = False, subthreshold_adaptation: bool = False, spike_triggered_adaptation: bool = False, hw_voltage_trace_available: bool = False, hw_spikes_available: bool = False)

Bases: object

__init__(leaky: bool = True, fire: bool = True, refractory: bool = False, exponential: bool = False, subthreshold_adaptation: bool = False, spike_triggered_adaptation: bool = False, hw_voltage_trace_available: bool = False, hw_spikes_available: bool = False)None

Initialize a code factory that can generate the necessary code for executing one integration step in simulation of the forward pass. Based on the passed arguments, subparts of the AdEx differential equations are picked to be simulated. However, the least complex version still includes all terms necessary to simulate a leaky integrator (LI). Per default, the leaky-integrate-and-fire model (LIF) is simulated.

Parameters
  • 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 that is 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.

If neither subthreshold_adaptation nor spike_triggered_adaptation are enabled, the adaptation won’t be simulated at all.

Methods

__init__([leaky, fire, refractory, …])

Initialize a code factory that can generate the necessary code for executing one integration step in simulation of the forward pass.

generate()

Attributes

adaptation_code_adaptation_dgl

adaptation_code_v_dgl

base_code

exponential_code

leak_term_code

non_unterjubel_reset_code

non_unterjubel_v_code

non_unterjubel_z_code

refractory_update

spike_code

spike_triggered_adaptation_code

subthreshold_adaptation_code

unterjubel_v_code

unterjubel_z_code

adaptation_code_adaptation_dgl = 'adaptation = adaptation * (1 - dt / tau_adaptation)'
adaptation_code_v_dgl = ' - adaptation'
base_code = '\n# Membrane increment\ndv = dt / c * (i{leak_term}{exponential_term}{adaptation_v_dgl})\n\n# Current\ni = i * (1 - dt / tau_syn) + input[ts]\n\n# Apply integration step\n{unterjubel_voltage}\n\n# Spikes\n{spike}\n{unterjubel_spike}\n\n# Adaptation\n{adaptation_adaptation_dgl}{subthreshold_adaptation}        {spike_triggered_adaptation}\n\n# Reset\n{non_unterjubel_reset}\n\n# Refractory update\n{refractory_update}\n'
exponential_code = ' + g_l * exp_slope * exp((v - exp_threshold) / exp_slope)'
generate()str
leak_term_code = ' + g_l * (leak - v)'
non_unterjubel_reset_code = 'v = (1 - z.detach()) * v + z.detach() * reset'
non_unterjubel_v_code = 'v = v + dv'
non_unterjubel_z_code = 'z = spike'
refractory_update = 'z, v, ref_state = refractory_update(\n    z, v, ref_state, spikes_hw[ts], membrane_hw[ts],\n    refractory_time=refractory_time, reset=reset, dt=dt)'
spike_code = 'spike = spiking_threshold(v - threshold, method, alpha)'
spike_triggered_adaptation_code = ' + b * z'
subthreshold_adaptation_code = ' + dt / tau_adaptation * a * (v - leak)'
unterjubel_v_code = 'v = Unterjubel.apply(dv + v, membrane_hw[ts])'
unterjubel_z_code = 'z = Unterjubel.apply(spike, spikes_hw[ts])'