norse.torch.functional.superspike module¶
- class norse.torch.functional.superspike.SuperSpike(*args, **kwargs)[source]¶
Bases:
torch.autograd.function.Function
SuperSpike surrogate gradient as described in Section 3.3.2 of
F. Zenke, S. Ganguli, “SuperSpike: Supervised Learning in Multilayer Spiking Neural Networks”, Neural Computation 30, 1514–1541 (2018), doi:10.1162/neco_a_01086
- static backward(ctx, grad_output)[source]¶
Defines a formula for differentiating the operation.
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward()
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward()
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward()
will havectx.needs_input_grad[0] = True
if the first input toforward()
needs gradient computated w.r.t. the output.
- static forward(ctx, input_tensor, alpha)[source]¶
Performs the operation.
This function is to be overridden by all subclasses.
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
The context can be used to store arbitrary data that can be then retrieved during the backward pass.
- Return type