engine.ensemble

Ensembles (layers) manage neuron collections by fixing their size, extending select attribute tensors, and handling layer-aware operations such as heterogeneous parameter initialization and normalization.

Note

Ensemble instance attributes are 1D tensors corresponding to potentially heterogeneous parameters and states of neurons (tensor elements) whose behavior is prescribed by their parent class (e.g., LIFNeuron).

Ensembles can be initialized programmatically or from a configuration YAML containing neuron parameters and their generation method (fixed, zipped, grid, or drawn from a distribution). Forward calls invoke the parent neuron class method.

Example

Initialize an ensemble of basic analog neurons, inheriting default parameters and behavior from AnalogNeuron:

>>> from sapicore.engine.ensemble.spiking import LIFEnsemble
>>> layer = LIFEnsemble(num_units = 10)

See also

Sweep

For built-in parameter sweep utility methods.

class engine.ensemble.Ensemble(num_units: int = 1, **kwargs)

Ensemble base class. Provides generic implementations of tensor expansion and parameter diversification.

_extensible_props_

The subset of this object’s configurable property names (_config_props_) that needs to be duplicated num_units times. Defaults to None, in which case all _config_props_ are assumed extensible. In the rare case where no configurable properties should be extended, use an empty tuple.

Type:

tuple[str]

forward(data: Tensor) dict

Processes the ensemble using the size-agnostic forward method of its neuron parent class.

Parameters:

data (Tensor) – External input to be processed by this ensemble.

Returns:

Dictionary containing the numeric state tensor voltage, per the parent class method.

Return type:

dict

Warning

If population-aware operations are necessary (e.g., layer-wise normalization), those should go here.

property num_units

Number of functional units represented by this object.

Neurons are singletons by coercion, as they are meant to express and encapsulate unit dynamics. Derivatives of Ensemble can modify this property and duplicate units as necessary.

Modules

engine.ensemble.analog

Analog ensemble variants.

engine.ensemble.spiking

Spiking ensemble variants.