hxtorch.spiking.functional.eventprop.EventPropNeuronFunction
-
class
hxtorch.spiking.functional.eventprop.
EventPropNeuronFunction
(*args, **kwargs) Bases:
torch.autograd.function.Function
Define gradient using adjoint code (EventProp) from norse
-
__init__
(*args, **kwargs) Initialize self. See help(type(self)) for accurate signature.
Methods
backward
(ctx, grad_spikes, grad_membrane, …)Implements ‘EventProp’ for backward.
forward
(ctx, input, leak, reset, threshold, …)Forward function returning hardware data if given or otherwise integrating LIF neuron dynamics, therefore generating spikes at positions > 0.
Attributes
-
static
backward
(ctx, grad_spikes: torch.Tensor, grad_membrane: torch.Tensor, grad_current: torch.Tensor) → Tuple[Optional[torch.Tensor], …] Implements ‘EventProp’ for backward.
- Parameters
grad_spikes – Gradient with respect to output spikes.
grad_membrane – Gradient with respect to membrane trace. (Not considered in EventProp algorithm, therefore not used further)
grad_current – Gradient with respect to current. (Not considered in EventProp algorithm, therefore not used further)
- Returns
Gradient given by adjoint function lambda_i of current.
-
static
forward
(ctx, input: torch.Tensor, leak: torch.Tensor, reset: torch.Tensor, threshold: torch.Tensor, tau_syn: torch.Tensor, tau_mem: torch.Tensor, hw_data: Optional[torch.Tensor] = None, dt: float = 1e-06) → Tuple[torch.Tensor] Forward function returning hardware data if given or otherwise integrating LIF neuron dynamics, therefore generating spikes at positions > 0.
- Parameters
input – Weighted input spikes in shape (2, batch, time, neurons). input[0] holds graded spikes, input[1] holds zero-tensor with same shape as placeholder to allow backpropagation of two (batch, time, neurons)-shaped tensors.
leak – The leak voltage as torch.Tensor.
reset – The reset voltage as torch.Tensor.
threshold – The threshold voltage as torch.Tensor.
tau_syn – The synaptic time constant as torch.Tensor.
tau_mem – The membrane time constant as torch.Tensor.
dt – Step width of integration.
hw_data – Optionally available observables from hardware.
- TODO: Issue 4044. The current LIF implementation differs from
hxtorch.spiking.functional.cuba_lif_integration.
- Returns
Returns the spike trains, membrane and current traces. All tensors are of shape (batch, time, neurons).
-