Note

This documentation is for a development version. Click here for the latest stable release (v1.3.0).

nengo_spa

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.

See also

nengo_spa.modules.BasalGanglia

Default basal ganglia network

nengo_spa.modules.Thalamus

Default thalamus network

Examples

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:

Attributes
activeActionSelection

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

builtbool

Indicates whether the action selection system has been built successfully.

bgnengo.Network

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

thalamusnengo.Network

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

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

Creates a node that inhibits all ensembles in a network.

Parameters
netnengo.Network

Network to inhibit.

strengthfloat

Strength of the inhibition.

**kwargsdict

Additional keyword arguments for the created connections from the node to the inhibited ensemble neurons.

Returns
nengo.Node

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

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

Defines a potential action within an ActionSelection context.

Parameters
  • name (str) – 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.

Returns

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

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

Base class for SPA networks or modules.

SPA modules are networks ethat 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
Parameters
labelstr, optional

Name of the network.

seedint, optional

Random number seed for the network.

add_to_containerbool, optional

Determines if this network will be added to the current container.

vocabsVocabularyMap, optional

Maps from integer dimensionalities to the associated default vocabularies.

Attributes
vocabsVocabularyMap

Maps from integer dimensionalities to the associated default vocabularies.

property 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.

Parameters
objnengo.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.

Parameters
objnengo.base.NengoObject

Nengo object to use as an output of the network.

vocabVocabulary

Vocabulary to assign to the output.

nengo_spa.sym

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

nengo_spa.operators.dot

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.