AllToAll

AllToAll#

class braintools.conn.AllToAll(include_self_connections=False, weight=None, delay=None, **kwargs)#

Fully connected network where every neuron connects to every other neuron.

Parameters:
  • include_self_connections (bool) – Whether neurons connect to themselves.

  • weight (Initialization | float | int | ndarray | Array | Quantity | None) – Weight initialization for all connections. Bare scalars stay dimensionless; pass a brainunit Quantity (e.g. 0.5 * u.nS) for physical units. If None, no weights are generated.

  • delay (Initialization | float | int | ndarray | Array | Quantity | None) – Delay initialization for all connections. Bare scalars stay dimensionless; pass a brainunit Quantity (e.g. 1.0 * u.ms) for physical units. If None, no delays are generated.

Notes

The output is dense by nature (N_pre * N_post edges, minus the diagonal when self-connections are excluded on a square block). Edges are built directly in row-major (pre, post) order without intermediate index grids. This is host-side NumPy build-time code; it is not traceable by jax.jit, jax.vmap or jax.grad.

Examples

>>> import brainunit as u
>>> from braintools.conn import AllToAll
>>> from braintools.init import Constant
>>> all_to_all = AllToAll(
...     weight=Constant(0.5 * u.nS),
...     delay=Constant(1.0 * u.ms)
... )
>>> result = all_to_all(pre_size=50, post_size=50)
>>> result.n_connections
2450
generate(pre_size, post_size, pre_positions=None, post_positions=None, **kwargs)[source]#

Generate all-to-all connections.

Return type:

ConnectionResult