class nengo_spa.ActionSelection[source]

Implements an action selection system with basal ganglia and thalamus.

The ActionSelection instance has to be used as context manager and each potential action is defined by an ifmax call providing an expression for the utility value and any number of effects (routing of information) to activate when this utility value is highest of all.


Class attribute providing the currently active ActionSelection instance (if any).


Indicates whether the action selection system has been built successfully.


Basal ganglia network. Available after the action selection system has been built.


Thalamus network. Available after the action selection system has been built.


See also

Default basal ganglia network
Default thalamus network


with ActionSelection():
    ifmax(dot(state, sym.A), sym.B >> state)
    ifmax(dot(state, sym.B), sym.C >> state)
    ifmax(dot(state, sym.C), sym.A >> state)

This will route the B Semantic Pointer to state when state is more similar to A than any of the other Semantic Pointers. Similarly, C will be routed to state when state is B. Once, state is C, it will be reset to A and the cycle begins anew.

Further action selection examples:

nengo_spa.create_inhibit_node(net, strength=2.0, **kwargs)[source]

Creates a node that inhibits all ensembles in a network.

  • net (nengo.Network) – Network to inhibit.
  • strength (float) – Strength of the inhibition.
  • kwargs (dict) – Additional keyword arguments for the created connections from the node to the inhibited ensemble neurons.

Node that can be connected to, to provide an inhibitory signal to the network.

Return type:


nengo_spa.ifmax([name, ]condition, actions)

Defines a potential aciton within an ActionSelection context.

  • name (str, optional) – Name for the action. Can be omitted.
  • condition – The utility value for the given actions.
  • actions – The actions to activate if the given utility is the highest.

Nengo object that can be connected to, to provide additional input to the utility value.

Return type:


class nengo_spa.Network(label=None, seed=None, add_to_container=None, vocabs=None)[source]

Bases:, nengo.config.SupportDefaultsMixin, nengo_spa.connectors.SpaOperatorMixin

Base class for SPA networks or modules.

SPA modules are networks that declare their inputs and outputs with associated Vocabulary instances. These inputs and outputs can then be be used in the SPA syntax, for example module1.output >> module2.input. Inputs and outputs named default can be omitted in the SPA syntax so that one can write module1 >> module2.

Furthermore, SPA modules allow to configure parameters of contained SPA modules, for example:

with spa.Network() as net:
    net.config[spa.State].vocab = 32
    state = spa.State()  # Will now have a 32-dimensional vocabulary
  • label (str, optional) – Name of the network.
  • seed (int, optional) – Random number seed for the network.
  • add_to_container (bool, optional) – Determines if this network will be added to the current container.
  • vocabs (VocabularyMap, optional) – Maps from integer dimensionalities to the associated default vocabularies.

Maps from integer dimensionalities to the associated default vocabularies.


(Config) Configuration for this network.

classmethod get_input_vocab(obj)[source]

Get the vocabulary associated with an network input obj.

classmethod get_output_vocab(obj)[source]

Get the vocabulary associated with an network output obj.

declare_input(obj, vocab)[source]

Declares a network input.

  • obj (nengo.base.NengoObject) – Nengo object to use as an input to the network.
  • vocab (Vocabulary) – Vocabulary to assign to the input.
declare_output(obj, vocab)[source]

Declares a network output.

  • obj (nengo.base.NengoObject) – Nengo object to use as an output of the network.
  • vocab (Vocabulary) – Vocabulary to assign to the output.

Provides Semantic Pointer symbols for symbolic expressions that are not tied to a single vocabulary. The vocabulary will be determined from the context. To use a symbol access it as an attribute on this object.

For example the following:

sym.A * sym.B >> state

is equivalent to:

state.vocab.parse('A * B') >> state

Further members

Commonly used classes and functions are accessible at the top level of the nengo_spa package.

nengo_spa.vocabulary.Vocabulary A collection of semantic pointers, each with their own text label.

SPA Modules

nengo_spa.modules.AssociativeMemory General associative memory network.
nengo_spa.modules.IAAssocMem Associative memory based on the IA network.
nengo_spa.modules.ThresholdingAssocMem Associative memory based on Thresholding.
nengo_spa.modules.WTAAssocMem Associative memory based on the WTA network.
nengo_spa.modules.BasalGanglia Winner take all network, typically used for action selection.
nengo_spa.modules.Bind Network for binding together two inputs.
nengo_spa.modules.Compare Computes the dot product of two inputs.
nengo_spa.modules.Product Multiplies two scalars.
nengo_spa.modules.Scalar Represents a single scalar.
nengo_spa.modules.State Represents a single vector, with optional memory.
nengo_spa.modules.Thalamus Inhibits non-selected actions.
nengo_spa.modules.Transcode Transcode from, to, and between Semantic Pointers.

Examination of Semantic Pointers

nengo_spa.examine.pairs Return expressions for all possible combinations to bind vocab’s keys.
nengo_spa.examine.similarity Return the similarity between simulation data and Semantic Pointers.
nengo_spa.examine.text Return a human-readable text version of the provided vector.

Operators Dot-product between a and b.
nengo_spa.operators.reinterpret Reinterpret source Semantic Pointer as part of vocabulary vocab.
nengo_spa.operators.translate Translate source Semantic Pointer to vocabulary vocab.