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
Wof shape(n_pre, n_post)stored in Compressed Sparse Column (CSC) order. For each postsynaptic neuronjthat fires (post_spike[j]isTrueor 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
Ware the CSR arrays ofW.T, the operation reduces toupdate_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 viabrainunit.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 withweight.post_spike (
Array) – Binary or boolean postsynaptic spike array, with shape(n_post,). BooleanTrueor any nonzero float indicates a spike.w_min (
Quantity|Array|Number|None) – Lower/upper bounds for weight clipping (same units asweight). IfNone, the corresponding bound is not applied.w_max (
Quantity|Array|Number|None) – Lower/upper bounds for weight clipping (same units asweight). IfNone, 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 inputweight, in canonical CSC order.- Return type:
jax.Array or Quantity
See also
update_csc_on_binary_prePresynaptic-spike-triggered CSC weight update.
update_csr_on_binary_preThe 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, ... )