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.-
active
¶ Class attribute providing the currently active ActionSelection instance (if any).
- Type
-
built
¶ Indicates whether the action selection system has been built successfully.
- Type
bool
-
bg
¶ Basal ganglia network. Available after the action selection system has been built.
- Type
-
thalamus
¶ Thalamus network. Available after the action selection system has been built.
- Type
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:
-
-
nengo_spa.
create_inhibit_node
(net, strength=2.0, **kwargs)[source]¶ Creates a node that inhibits all ensembles in a network.
- Parameters
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.
- Returns
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.- Parameters
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.
- Returns
Nengo object that can be connected to, to provide additional input to the utility value.
- Return type
nengo.base.NengoObject
-
class
nengo_spa.
Network
(label=None, seed=None, add_to_container=None, vocabs=None)[source]¶ Bases:
nengo.network.Network
,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 examplemodule1.output >> module2.input
. Inputs and outputs nameddefault
can be omitted in the SPA syntax so that one can writemodule1 >> 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
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.
-
vocabs
¶ Maps from integer dimensionalities to the associated default vocabularies.
- Type
-
property
config
¶ (
Config
) Configuration for this network.
-
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
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.
- Parameters
obj (nengo.base.NengoObject) – Nengo object to use as an output of the network.
vocab (Vocabulary) – 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.
A collection of semantic pointers, each with their own text label. |
SPA Modules¶
General associative memory network. |
|
Associative memory based on the |
|
Associative memory based on |
|
Associative memory based on the |
|
Winner take all network, typically used for action selection. |
|
Network for binding together two inputs. |
|
Computes the dot product of two inputs. |
|
Multiplies two scalars. |
|
Represents a single scalar. |
|
Represents a single vector, with optional memory. |
|
Inhibits non-selected actions. |
|
Transcode from, to, and between Semantic Pointers. |
Examination of Semantic Pointers¶
Return expressions for all possible combinations to bind vocab’s keys. |
|
Return the similarity between simulation data and Semantic Pointers. |
|
Return a human-readable text version of the provided vector. |
Operators¶
Dot-product between a and b. |
|
Reinterpret source Semantic Pointer as part of vocabulary vocab. |
|
Translate source Semantic Pointer to vocabulary vocab. |