DelayAdjustedSTDP

class DelayAdjustedSTDP(lr_pos: float, lr_neg: float, tc_pos: float, tc_neg: float, interp_tolerance: float = 0.0, batch_reduction: Callable[[Tensor, tuple[int, ...]], Tensor] | None = None, inplace: bool = False, **kwargs)[source]

Bases: IndependentCellTrainer

Delay-adjusted pair-based spike-timing dependent plasticity trainer.

\[\begin{split}\begin{align*} w(t + \Delta t) - w(t) &= \eta_+ \exp\left(-\frac{\lvert t_\Delta(t) \rvert}{\tau_+} \right) [t_\Delta(t) \geq 0] \\ &+ \eta_- \exp\left(-\frac{\lvert t_\Delta(t) \rvert}{\tau_-} \right) [t_\Delta(t) < 0] \\ t_\Delta(t) &= t^f_\text{post} - t^f_\text{pre} - d(t) \end{align*}\end{split}\]

Where:

Times \(t\) and \(t_n^f\) are the current time and the time of the most recent spike from neuron \(n\) respectively, \(\Delta t\) is the duration of the simulation step, and \(d(t)\) are the learned delays.

The signs of the learning rates \(\eta_+\) and \(\eta_-\) control which terms are potentiative and which terms are depressive. The terms can be scaled for weight dependence on updating.

Mode

\(\text{sgn}(\eta_+)\)

\(\text{sgn}(\eta_-)\)

LTP Term(s)

LTD Term(s)

Hebbian

\(+\)

\(-\)

\(\eta_+\)

\(\eta_-\)

Anti-Hebbian

\(-\)

\(+\)

\(\eta_-\)

\(\eta_+\)

Potentiative Only

\(+\)

\(+\)

\(\eta_+, \eta_-\)

None

Depressive Only

\(-\)

\(-\)

None

\(\eta_+, \eta_-\)

Parameters:
  • lr_pos (float) – learning rate for updates when the last postsynaptic spike was more recent, \(\eta_+\).

  • lr_neg (float) – learning rate for updates when the last presynaptic spike was more recent, \(\eta_-\).

  • tc_pos (float) – time constant of exponential decay of adjusted trace when, the last postsynaptic was more recent, \(\tau_+\), in \(ms\).

  • tc_neg (float) – time constant of exponential decay of adjusted trace when, the last presynaptic was more recent, \(\tau_-\), in \(ms\).

  • interp_tolerance (float, optional) – maximum difference in time from an observation to treat as co-occurring, in \(\text{ms}\). Defaults to 0.0.

  • batch_reduction (Callable[[torch.Tensor, tuple[int, ...]], torch.Tensor] | None) – function to reduce updates over the batch dimension, torch.mean() when None. Defaults to None.

  • inplace (bool, optional) – if RecordTensor write operations should be performed in-place. Defaults to False.

Important

It is expected for this to be called after every trainable batch. Variables used are not stored (or are invalidated) if multiple batches are given before an update.

Note

The constructor arguments are hyperparameters and can be overridden on a cell-by-cell basis.

Note

batch_reduction can be one of the functions in PyTorch including but not limited to torch.sum(), torch.mean(), and torch.amax(). A custom function with similar behavior can also be passed in. Like with the included function, it should not keep the original dimensions by default.

See also

For more details and references, visit Delay-Adjusted Spike-Timing Dependent Plasticity (Delay-Adjusted STDP) in the zoo.

forward() None[source]

Processes update for given layers based on current monitor stored data.

register_cell(name: str, cell: Cell, /, **kwargs: Any) Unit[source]

Adds a cell with required state.

Parameters:
  • name (str) – name of the cell to add.

  • cell (Cell) – cell to add.

Keyword Arguments:
  • lr_pos (float) – learning rate for updates when the last postsynaptic spike was more recent.

  • lr_neg (float) – learning rate for updates when the last presynaptic spike was more recent.

  • tc_pos (float) – time constant of exponential decay of adjusted trace when, the last postsynaptic was more recent.

  • tc_neg (float) – time constant of exponential decay of adjusted trace when, the last presynaptic was more recent.

  • interp_tolerance (float) – maximum difference in time from an observation to treat as co-occurring.

  • batch_reduction (Callable[[torch.Tensor, tuple[int, ...]], torch.Tensor]) – function to reduce updates over the batch dimension.

  • inplace (bool, optional) – if RecordTensor write operations should be performed in-place. Defaults to False.

Returns:

specified cell, auxiliary state, and monitors.

Return type:

IndependentCellTrainer.Unit

Important

Any specified keyword arguments will override the default hyperparameters set on initialization. See DelayAdjustedSTDP for details.