spark.nn.brain#

Classes#

BrainMeta

Brain metaclass.

BrainConfig

Configuration class for Brain's.

Brain

Brain model.

Module Contents#

class spark.nn.brain.BrainMeta[source]#

Bases: spark.core.module.SparkMeta

Brain metaclass.

class spark.nn.brain.BrainConfig(__skip_validation__=False, **kwargs)[source]#

Bases: spark.core.config.BaseSparkConfig

Configuration class for Brain’s.

Parameters:

__skip_validation__ (bool)

input_map: dict[str, spark.core.specs.PortSpecs][source]#
output_map: dict[str, dict][source]#
modules_map: dict[str, spark.core.specs.ModuleSpecs][source]#
validate(is_partial=False, errors=None, current_path=['brain'])[source]#

Validates all fields in the configuration class.

Parameters:
Return type:

dict[str] | None

refresh_seeds()[source]#

Utility method to recompute all seed variables within the SparkConfig. Useful when creating several populations from the same config.

class spark.nn.brain.Brain(config=None, **kwargs)[source]#

Bases: spark.core.module.SparkModule

Brain model.

A brain is a pipeline object used to represent and coordinate a collection of neurons and interfaces. This implementation relies on a cache system to simplify parallel computations; every timestep all the modules in the Brain read from the cache, update its internal state and update the cache state. Note that this introduces a small latency between elements of the brain, which for most cases is negligible, and for such a reason it is recommended that only full neuron models and interfaces are used within a Brain.

Parameters:

config (BrainConfig)

config: BrainConfig[source]#
resolve_initialization_order()[source]#

Resolves the initialization order of the modules.

build(input_specs)[source]#

Build method.

Parameters:

input_specs (dict[str, spark.core.specs.PortSpecs])

reset()[source]#

Resets all the modules to its initial state.

__call__(**inputs)[source]#

Update brain’s states.

Parameters:

inputs (spark.core.payloads.SparkPayload)

Return type:

dict[str, spark.core.payloads.SparkPayload]

get_spikes_from_cache()[source]#

Collect the brain’s spikes.

Return type:

dict