DataRepresentation#
- class brainevent.DataRepresentation(*args, shape, buffers=None)[source]#
- property buffers#
Dict of all registered buffer names to their current values.
- classmethod fromdense(*args, **kwargs)[source]#
Construct a representation from a dense matrix.
The concrete signature is defined per family; every subclass takes the dense matrix as the first positional argument followed by format-specific keyword options. A permissive
*args, **kwargsis used here so each subclass can declare its own parameters without violating the Liskov substitution principle.- Parameters:
dense (jax.Array or brainunit.Quantity) – Dense
(num_pre, num_post)matrix to encode.**kwargs – Format-specific options (e.g.
num_connfor fixed-num connections,nsefor compressed-sparse formats).
- Returns:
A new instance of
clsencodingdense.- Return type:
- Raises:
NotImplementedError – On the abstract base; concrete subclasses must override.
UnsupportedOperationError – If the format cannot be reconstructed from a dense matrix (e.g. just-in-time connectivity).
- tocoo()[source]#
Convert to coordinate (COO) format.
- Returns:
The same logical matrix in COO format, shape unchanged.
- Return type:
brainunit.sparse.COO
- Raises:
NotImplementedError – On the abstract base; concrete subclasses must override.
- tocsc()[source]#
Convert to Compressed Sparse Column (CSC) format.
- Returns:
The same logical matrix in CSC format, shape unchanged.
- Return type:
- Raises:
NotImplementedError – On the abstract base; concrete subclasses must override.
- tocsr()[source]#
Convert to Compressed Sparse Row (CSR) format.
- Returns:
The same logical matrix in CSR format, shape unchanged.
- Return type:
- Raises:
NotImplementedError – On the abstract base; concrete subclasses must override.
- update_on_post(pre_trace, post_spike, w_min=None, w_max=None)[source]#
Apply a post-spike-triggered STDP update, returning a new matrix.
- Parameters:
pre_trace (jax.Array or brainunit.Quantity) – Pre-synaptic trace, shape
(shape[0],).post_spike (jax.Array) – Post-synaptic spikes, shape
(shape[1],).w_min (jax.Array, brainunit.Quantity, number, or None, optional) – Clip bounds;
Nonedisables the corresponding bound.w_max (jax.Array, brainunit.Quantity, number, or None, optional) – Clip bounds;
Nonedisables the corresponding bound.
- Returns:
A new matrix with updated values and identical structure.
- Return type:
- Raises:
NotImplementedError – On the abstract base; concrete subclasses must override.
UnsupportedOperationError – If the format has no per-synapse plastic weight (e.g. just-in-time connectivity).
See also
update_on_prePre-spike-triggered counterpart.
- update_on_pre(pre_spike, post_trace, w_min=None, w_max=None)[source]#
Apply a pre-spike-triggered STDP update, returning a new matrix.
- Parameters:
pre_spike (jax.Array) – Pre-synaptic spikes, shape
(shape[0],).post_trace (jax.Array or brainunit.Quantity) – Post-synaptic trace, shape
(shape[1],).w_min (jax.Array, brainunit.Quantity, number, or None, optional) – Clip bounds;
Nonedisables the corresponding bound.w_max (jax.Array, brainunit.Quantity, number, or None, optional) – Clip bounds;
Nonedisables the corresponding bound.
- Returns:
A new matrix with updated values and identical structure.
- Return type:
- Raises:
NotImplementedError – On the abstract base; concrete subclasses must override.
UnsupportedOperationError – If the format has no per-synapse plastic weight (e.g. just-in-time connectivity).
See also
update_on_postPost-spike-triggered counterpart.
- yw_to_w_transposed(y_dim_arr, w_dim_arr)[source]#
Per-synapse
w * ywithyindexed by the column (post) ofW.Adjoint counterpart of
yw_to_w(). Part of the per-synapse eligibility protocol used bybrainscale.- Parameters:
y_dim_arr (jax.Array or brainunit.Quantity) – Post-synaptic (column) vector, sized
shape[1].w_dim_arr (jax.Array or brainunit.Quantity) – Per-synapse weights. Some formats (e.g. fixed-num connections) accept
Nonehere, defaulting to the representation’s own values.
- Returns:
Per-synapse result.
- Return type:
jax.Array or brainunit.Quantity
- Raises:
NotImplementedError – On the abstract base; concrete subclasses must override.
UnsupportedOperationError – If the format has no per-synapse weight (e.g. just-in-time connectivity).
See also
yw_to_wyindexed by the row (pre) ofW.