DataRepresentation#
- class brainevent.DataRepresentation(*args, shape, buffers=None)[source]#
- property buffers#
Dict of all registered buffer names to their current values.
- dt2t(y_dim_arr, w_dim_arr)[source]#
Per-synapse
w * ywithyindexed by the row (pre) ofW.Part of the per-synapse eligibility protocol used by
brainscale. Concrete subclasses implement this directly when their storage can produce one value per represented synapse.- Parameters:
y_dim_arr (
Array|ndarray|Quantity) – Pre-synaptic (row) vector, sizedshape[0].w_dim_arr (
Array|ndarray|Quantity) – Per-synapse weights.
- Returns:
Per-synapse result.
- Return type:
Array|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 without a direct generator).
See also
dt2t_transposedyindexed by the column (post) ofW.
Notes
This is the protocol for the \(\mathbf{D}^{t}\boldsymbol{\epsilon}^{t-1}\) term of the D-RTRL (diagonal real-time recurrent learning) sensitivity update rule
\[\boldsymbol{\epsilon}^{t} \approx \mathbf{D}^{t}\boldsymbol{\epsilon}^{t-1} + \mathrm{diag}(\mathbf{D}_{f}^{t}) \otimes \mathbf{x}^{t}\]w_dim_arrsupplies the per-synapse entries of the Jacobian \(\mathbf{D}^{t}\) andy_dim_arrsupplies the previous-step eligibility trace \(\boldsymbol{\epsilon}^{t-1}\); the \(\mathrm{diag}(\mathbf{D}_{f}^{t}) \otimes \mathbf{x}^{t}\) term is accumulated separately by the caller (brainscale).
- dt2t_transposed(y_dim_arr, w_dim_arr)[source]#
Per-synapse
w * ywithyindexed by the column (post) ofW.Adjoint counterpart of
dt2t(). Part of the per-synapse eligibility protocol used bybrainscale.- Parameters:
y_dim_arr (
Array|ndarray|Quantity) – Post-synaptic (column) vector, sizedshape[1].w_dim_arr (
Array|ndarray|Quantity) – Per-synapse weights.
- Returns:
Per-synapse result.
- Return type:
Array|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
dt2tyindexed by the row (pre) ofW.
Notes
Adjoint counterpart of the \(\mathbf{D}^{t}\boldsymbol{\epsilon}^{t-1}\) protocol documented on
dt2t()— see there for the full D-RTRL update-rule context.
- 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(y_dim_arr, w_dim_arr)[source]#
Deprecated alias for
dt2t().Deprecated since version Use:
dt2t()instead. Will be removed in a future release.- Parameters:
y_dim_arr (
Array|ndarray|Quantity) – Pre-synaptic (row) vector, sizedshape[0].w_dim_arr (
Array|ndarray|Quantity) – Per-synapse weights.
- Returns:
Per-synapse result; see
dt2t().- Return type:
Array|Quantity
See also
dt2tReplacement for this method.
- yw_to_w_transposed(y_dim_arr, w_dim_arr)[source]#
Deprecated alias for
dt2t_transposed().Deprecated since version Use:
dt2t_transposed()instead. Will be removed in a future release.- Parameters:
y_dim_arr (
Array|ndarray|Quantity) – Post-synaptic (column) vector, sizedshape[1].w_dim_arr (
Array|ndarray|Quantity) – Per-synapse weights.
- Returns:
Per-synapse result; see
dt2t_transposed().- Return type:
Array|Quantity
See also
dt2t_transposedReplacement for this method.