LinearHomeostasis¶
- class LinearHomeostasis(plasticity: float, target: float | None, param: Literal['weight', 'bias', 'delay'], batch_reduction: Callable[[Tensor, tuple[int, ...]], Tensor] | None = None, **kwargs)[source]¶
Bases:
IndependentCellTrainerLinear homeostatic regulation.
When
param == "weight":\[w(t + \Delta t) - w(t) = \lambda \frac{r^* - r}{r^*}\]When
param == "bias":\[b(t + \Delta t) - b(t) = \frac{\lambda}{L} \sum{\frac{r^* - r}{r^*}}\]When
param == "delay":\[d(t + \Delta t) - d(t) = -\lambda \frac{r^* - r}{r^*}\]Where:
Times \(t\) is the current time, \(\Delta t\) is the duration of the simulation step, and \(L\) is the number of outputs corresponding to each bias term (for connections with a trainable bias).
- Parameters:
plasticity (float) – learning rate for updates, \(\lambda\).
target (float | None, optional) – target rate for postsynaptic spikes, \(r^*\). Required to be specified on update when
None.param (Literal["weight", "bias", "delay"]) – specified parameter to update.
batch_reduction (Callable[[torch.Tensor, tuple[int, ...]], torch.Tensor] | None, optional) – function to reduce updates over the batch dimension,
torch.mean()whenNone. Defaults toNone.
Caution
The sign of \(\lambda\) is reversed in the case of training
"delay"parameters. Generally, the sign ofplasticityshould be positive for the updater to behave in the manner expected, although this is not enforced.Note
Updates are averaaged along the “receptive” dimension, i.e. the individual spike rates corresponding to each parameter.
Note
For the purposes of parameter bounding, the update term is split by clamping values. The sequence of operations follows:
The receptive dimension is reduced.
The updates are split into positive and negative parts.
The batch dimension is reduced.
See also
For more details and references, visit Linear Homeostatic Plasticity in the zoo.
- forward(target: float | Tensor | None = None, cells: Sequence[str] | None = None) None[source]¶
Processes update for given layers based on current monitor stored data.
- Parameters:
target (float | torch.Tensor | None) – target rate for postsynaptic spikes, \(r^*\). Required to be specified on update if the default is
Noneand will try to use the default whenNone. Defaults toNone.cells (Sequence[str] | None) – names of the cells to update, all cells if
None. Defaults toNone.
Shape
target:\(B \times N_0 \times \cdots\) or \(1 \times N_0 \times \cdots\)
- Where:
\(B\) is the batch size.
\(N_0, \ldots\) are the dimensions of the postsynaptic spikes.
- register_cell(name: str, cell: Cell, /, **kwargs: Any) Unit[source]¶
Adds a cell with required state.
- Parameters:
- Keyword Arguments:
plasticity (float) – learning rate for updates, \(\lambda\).
target (float | None, optional) – target rate for postsynaptic spikes, \(r^*\). Required to be specified on update when
None.param (Literal["weight", "bias", "delay"]) – specified parameter to update.
batch_reduction (Callable[[torch.Tensor, tuple[int, ...]], torch.Tensor] | None) – function to reduce updates over the batch dimension,
torch.mean()whenNone.
- Returns:
specified cell, auxiliary state, and monitors.
- Return type:
Important
The
targetparameter can be specified as a tensor here, in which case it won’t need to be passed in on eachforward()call but can still have a different value for each output. It must have the same shape as the output spikes of thecell.neuron. The batch dimension can have a size of 1 regardless of the batch sie.Important
Any specified keyword arguments will override the default hyperparameters set on initialization. See
DelayAdjustedSTDPfor details.