brainevent.update_csc_on_binary_post

brainevent.update_csc_on_binary_post#

brainevent.update_csc_on_binary_post(weight, indices, indptr, pre_trace, post_spike, w_min=None, w_max=None, *, shape, backend=None)[source]#

Update CSC synaptic weights triggered by postsynaptic binary spike events.

Implements the postsynaptic component of additive spike-timing-dependent plasticity (STDP) for a weight matrix W of shape (n_pre, n_post) stored in Compressed Sparse Column (CSC) order. For each postsynaptic neuron j that fires (post_spike[j] is True or nonzero), every stored synapse (i, j) is updated:

W[i, j] <- clip(W[i, j] + pre_trace[i], w_min, w_max)

This is the favorable direction for CSC: postsynaptic spikes index the stored column axis, so the update streams directly over the CSC arrays with no permutation. Because the CSC arrays of W are the CSR arrays of W.T, the operation reduces to update_csr_on_binary_pre() on the transposed shape.

Parameters:
  • weight (Quantity | Array | Number) – Sparse synaptic weight array in CSC data order, with shape (nse,). May carry physical units via brainunit.Quantity.

  • indices (ndarray | Array) – Row index array of the CSC format, with shape (nse,) and integer dtype.

  • indptr (ndarray | Array) – Column pointer array of the CSC format, with shape (n_post + 1,) and integer dtype.

  • pre_trace (Quantity | Array) – Presynaptic eligibility trace, with shape (n_pre,). Must be unit-compatible with weight.

  • post_spike (Array) – Binary or boolean postsynaptic spike array, with shape (n_post,). Boolean True or any nonzero float indicates a spike.

  • w_min (Quantity | Array | Number | None) – Lower/upper bounds for weight clipping (same units as weight). If None, the corresponding bound is not applied.

  • w_max (Quantity | Array | Number | None) – Lower/upper bounds for weight clipping (same units as weight). If None, the corresponding bound is not applied.

  • shape (Tuple[int, int]) – Full matrix shape (n_pre, n_post).

  • backend (str | None) – Compute backend forwarded to the underlying primitive.

Returns:

Updated weight array with the same shape (nse,) and units as the input weight, in canonical CSC order.

Return type:

jax.Array or Quantity

See also

update_csc_on_binary_pre

Presynaptic-spike-triggered CSC weight update.

update_csr_on_binary_pre

The CSR primitive this reuses.

Examples

>>> import jax.numpy as jnp
>>> import brainevent
>>> W = jnp.array([[0.5, 0.0, 0.8],
...                [0.0, 0.3, 0.2]], dtype=jnp.float32)
>>> csc = brainevent.CSC.fromdense(W)
>>> pre_trace = jnp.array([0.1, -0.05], dtype=jnp.float32)
>>> post_spike = jnp.array([True, False, True])
>>> new_w = brainevent.update_csc_on_binary_post(
...     csc.data, csc.indices, csc.indptr, pre_trace, post_spike,
...     shape=csc.shape,
... )