brainevent.update_csc_on_binary_pre#
- brainevent.update_csc_on_binary_pre(weight, indices, indptr, pre_spike, post_trace, w_min=None, w_max=None, *, shape, backend=None)[source]#
Update CSC synaptic weights triggered by presynaptic binary spike events.
Implements the presynaptic 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 presynaptic neuronithat fires (pre_spike[i]isTrueor nonzero), every stored synapse(i, j)is updated:W[i, j] <- clip(W[i, j] + post_trace[j], w_min, w_max)This is the unfavorable direction for CSC (presynaptic spikes index the row axis, not the stored column axis). The function builds the row-major (CSR-like) view of the structure and a permutation
permmapping each row-major slot back to the canonical CSCweightorder, then delegates toupdate_csr_on_binary_post(), which scatters the per-synapse updates back throughperm.- 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_spike (
Array) – Binary or boolean presynaptic spike array, with shape(n_pre,). BooleanTrueor any nonzero float indicates a spike.post_trace (
Quantity|Array) – Postsynaptic eligibility trace, with shape(n_post,). Must be unit-compatible withweight.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_postPostsynaptic-spike-triggered CSC weight update.
update_csr_on_binary_postThe CSR primitive this reuses.
brainevent.csc_to_csr_indexBuilds the CSR-like view and
perm.
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_spike = jnp.array([True, False]) >>> post_trace = jnp.array([0.1, 0.2, 0.05], dtype=jnp.float32) >>> new_w = brainevent.update_csc_on_binary_pre( ... csc.data, csc.indices, csc.indptr, pre_spike, post_trace, ... shape=csc.shape, ... )