norse.torch.functional.regularization module¶
This module contains functional components for regularization operations on spiking layers, where it can be desirable to regularize spikes, membrane parameters, or other properties over time.
In this functional module, the aim is to collect some state s
for each
forward step. The collection depends on the output of the layer which, by
default, simply just counts spikes. It is the job of the user to include the
regularization in an error term later.
Read more on Wikipedia.
- norse.torch.functional.regularization.regularize_step(z, s, accumulator=<function spike_accumulator>, state=None)[source]¶
Takes one step for a regularizer that aggregates some information (based on the spike_accumulator function), which is pushed forward and returned for future inclusion in an error term.
- Parameters
z (torch.Tensor) – Spikes from a cell
s (Any) – Neuron state
accumulator (Accumulator) – Accumulator that decides what should be accumulated
state (Optional[Any]) – The regularization state to be aggregated. Typically some numerical value like a count. Defaults to None
- Return type
- Returns
A tuple of (spikes, regularizer state)
- norse.torch.functional.regularization.spike_accumulator(z, _, state=None)[source]¶
A spike accumulator that aggregates spikes and returns the total sum as an integer.
- Parameters
z (torch.Tensor) – Spikes from some cell
s (Any) – Cell state
state (Optional[int]) – The regularization state to be aggregated to. Defaults to 0.
- Return type
- Returns
A new RegularizationState containing the aggregated data
- norse.torch.functional.regularization.voltage_accumulator(z, s, state=None)[source]¶
A spike accumulator that aggregates membrane potentials over time. Requires that the input state
s
has av
property (for voltage).- Parameters
z (torch.Tensor) – Spikes from some cell
s (Any) – Cell state
state (Optional[torch.Tensor]) – The regularization state to be aggregated to.
entries. (Defaults to zeros for all) –
- Return type
- Returns
A new RegularizationState containing the aggregated data