hxtorch.spiking.functional.eventprop.EventPropNeuron
-
class
hxtorch.spiking.functional.eventprop.
EventPropNeuron
(*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, params, dt[, hw_data])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, params: NamedTuple, dt: float, hw_data: Optional[torch.Tensor] = None) → 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.
params – CUBALIFParams object holding neuron parameters.
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).
-