norse.torch.functional.adjoint.lsnn_adjoint module¶
- class norse.torch.functional.adjoint.lsnn_adjoint.LSNNAdjointFunction(*args, **kwargs)[source]¶
Bases:
torch.autograd.function.Function
- static backward(ctx, doutput, lambda_v, lambda_i, lambda_b)[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, z, v, i, b, input_weights, recurrent_weights, p=LSNNParameters(tau_syn_inv=tensor(200.), tau_mem_inv=tensor(100.), tau_adapt_inv=tensor(0.0012), v_leak=tensor(0.), v_th=tensor(1.), v_reset=tensor(0.), beta=tensor(1.8000), method='super', alpha=100.0), dt=0.001)[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.
- class norse.torch.functional.adjoint.lsnn_adjoint.LSNNFeedForwardAdjointFunction(*args, **kwargs)[source]¶
Bases:
torch.autograd.function.Function
- static backward(ctx, doutput, lambda_v, lambda_i, lambda_b)[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, v, i, b, p=LSNNParameters(tau_syn_inv=tensor(200.), tau_mem_inv=tensor(100.), tau_adapt_inv=tensor(0.0012), v_leak=tensor(0.), v_th=tensor(1.), v_reset=tensor(0.), beta=tensor(1.8000), method='super', alpha=100.0), dt=0.001)[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.
- norse.torch.functional.adjoint.lsnn_adjoint.lsnn_adjoint_step(input, s, input_weights, recurrent_weights, p=LSNNParameters(tau_syn_inv=tensor(200.), tau_mem_inv=tensor(100.), tau_adapt_inv=tensor(0.0012), v_leak=tensor(0.), v_th=tensor(1.), v_reset=tensor(0.), beta=tensor(1.8000), method='super', alpha=100.0), dt=0.001)[source]¶
Implementes a single euler forward and adjoint backward step of a lif neuron with adaptive threshhold and current based exponential synapses.
- Parameters
input (torch.Tensor) – input spikes from other cells
s (LSNNState) – current state of the LSNN unit
input_weights (torch.Tensor) – synaptic weights for input spikes
recurrent_weights (torch.Tensor) – recurrent weights for recurrent spikes
p (LSNNParameters) – parameters of the LSNN unit
dt (torch.Tensor) – integration timestep
- norse.torch.functional.adjoint.lsnn_adjoint.lsnn_feed_forward_adjoint_step(input, s, p=LSNNParameters(tau_syn_inv=tensor(200.), tau_mem_inv=tensor(100.), tau_adapt_inv=tensor(0.0012), v_leak=tensor(0.), v_th=tensor(1.), v_reset=tensor(0.), beta=tensor(1.8000), method='super', alpha=100.0), dt=0.001)[source]¶
Implementes a single euler forward and adjoint backward step of a lif neuron with adaptive threshhold and current based exponential synapses.
- Parameters
input (torch.Tensor) – input spikes from other cells
v (torch.Tensor) – membrane voltage state of this cell
i (torch.Tensor) – synaptic input current state of this cell
b (torch.Tensor) – state of the adaptation variable
input_weights (torch.Tensor) – synaptic weights for input spikes
recurrent_weights (torch.Tensor) – recurrent weights for recurrent spikes
p (LSNNParameters) – parameters to use for the lsnn unit
dt (torch.Tensor) – integration timestep