Semantic Pointer Architecture

The Semantic Pointer Architecture provides an approach to building cognitive models implemented with large-scale spiking neural networks.

Nengo includes a nengo.spa module that provides a simple interface for building models with the Semantic Pointer Architecture. See the following examples for demonstrations of how nengo.spa works.

API reference

class nengo.spa.SPA(label=None, seed=None, add_to_container=None, vocabs=None)[source]

Base class for SPA models.

This expands the standard Network system to support structured connections that use Semantic Pointers and associated vocabularies in their definitions.

To build a SPA model, you can either use with or create a subclass of this SPA class.

If you use the with statement, any attribute added to the SPA network will be accessible for SPA connections.

If you chose to create a subclass, any Module object that is assigned to a member variable will automatically be accessible by the SPA connection system.

As an example, the following code will build three modules (two buffers and a memory) that can be referred to as a, b, and c, respectively.

First, the example with a with statement:

example = spa.Spa()

with example:
    example.a = spa.Buffer(dimensions=8)
    example.b = spa.Buffer(dimensions=16)
    example.c = spa.Memory(dimensions=8)

Now, the example with a subclass:

class Example(spa.SPA):
    def __init__(self):
        with self:
            self.a = spa.Buffer(dimensions=8)
            self.b = spa.Buffer(dimensions=16)
            self.c = spa.Memory(dimensions=8)

These names can be used by special modules that are aware of these names. As an example, the Cortical module allows you to form connections between these modules in ways that are aware of semantic pointers:

with example:
    example.a = spa.Buffer(dimensions=8)
    example.b = spa.Buffer(dimensions=16)
    example.c = spa.Memory(dimensions=8)
    example.cortical = spa.Cortical(spa.Actions(
            'b=a*CAT', 'c=b*~CAT'))

For complex cognitive control, the key modules are the spa.BasalGanglia and the spa.Thalamus. Together, these allow us to define complex actions using the spa.Action syntax:

class SequenceExample(spa.SPA):
    def __init__(self):
        self.state = spa.Memory(dimensions=32)

        actions = spa.Actions('dot(state, A) --> state=B',
                              'dot(state, B) --> state=C',
                              'dot(state, C) --> state=D',
                              'dot(state, D) --> state=E',
                              'dot(state, E) --> state=A')

        self.bg = spa.BasalGanglia(actions=actions)
        self.thal = spa.Thalamus(self.bg)
get_module(name)[source]

Return the module for the given name.

get_default_vocab(dimensions)[source]

Return a Vocabulary with the desired dimensions.

This will create a new default Vocabulary if one doesn’t exist.

get_module_input(name)[source]

Return the object to connect into for the given name.

The name will be either the same as a module, or of the form <module_name>_<input_name>.

get_module_output(name)[source]

Return the object to connect into for the given name.

The name will be either the same as a module, or of the form <module_name>_<output_name>.

similarity(data, probe, vocab=None)[source]

Return the similarity between the probed data and vocab.

If no vocabulary is provided, the vocabulary associated with probe.target will be used.

Parameters:

data: ProbeDict

Collection of simulation data returned by sim.run() function call.

probe: Probe

Probe with desired data.

vocab : Vocabulary, optional (Default: None)

The vocabulary to compare with. If None, uses the vocabulary associated with probe.target.

nengo.spa.enable_spa_params(model)[source]

Enables the SPA specific parameters on a model.

Parameters:

model : Network

Model to activate SPA specific parameters for.

class nengo.spa.SemanticPointer(data, rng=None)[source]

A Semantic Pointer, based on Holographic Reduced Representations.

Operators are overloaded so that + and - are addition, * is circular convolution, and ~ is the inversion operator.

length()[source]

Return the L2 norm of the vector.

normalize()[source]

Modify the vector to have an L2 norm of 1.

randomize(N=None, rng=None)[source]

Set the vector to be a random vector with L2 norm of 1.

make_unitary()[source]

Make the vector unitary.

convolve(other)[source]

Return the circular convolution of two SemanticPointers.

compare(other)[source]

Return the similarity between two SemanticPointers.

This is the normalized dotproduct, or (equivalently), the cosine of the angle between the two vectors.

dot(other)[source]

Return the dot product of the two vectors.

distance(other)[source]

Return a distance measure between the vectors.

This is 1-cos(angle), so that it is 0 when they are identical, and the distance gets larger as the vectors are farther apart.

copy()[source]

Return another semantic pointer with the same data.

mse(other)[source]

Return the mean-squared-error between two vectors.

get_convolution_matrix()[source]

Return the matrix that does a circular convolution by this vector.

This should be such that A*B == dot(A.get_convolution_matrix, B.v).

class nengo.spa.Vocabulary(dimensions, randomize=True, unitary=False, max_similarity=0.1, include_pairs=False, rng=None)[source]

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

The Vocabulary can also act as a dictionary, with keys as the names of the semantic pointers and values as the SemanticPointer objects themselves. If it is asked for a pointer that does not exist, one will be automatically created.

Parameters:

dimensions : int

Number of dimensions for each semantic pointer.

randomize : bool, optional (Default: True)

Whether to randomly generate pointers. If False, the semantic pointers will be [1, 0, 0, ...], [0, 1, 0, ...], [0, 0, 1, ...] and so on.

unitary : bool or list, optional (Default: False)

If True, all generated pointers will be unitary. If a list of strings, any pointer whose name is in the list will be forced to be unitary when created.

max_similarity : float, optional (Default: 0.1)

When randomly generating pointers, ensure that the cosine of the angle between the new pointer and all existing pointers is less than this amount. If the system is unable to find such a pointer after 100 tries, a warning message is printed.

include_pairs : bool, optional (Default: False)

Whether to keep track of all pairs of pointers as well. This is helpful for determining if a vector is similar to A*B (in addition to being similar to A or B), but exponentially increases the processing time.

rng : numpy.random.RandomState, optional (Default: None)

The random number generator to use to create new vectors.

Attributes

include_pairs (bool) Whether to keep track of all pairs of pointers as well. This is helpful for determining if a vector is similar to A*B (in addition to being similar to A or B), but exponentially increases the processing time.
key_pairs (list) The names of all pairs of semantic pointers (e.g., ['A*B', 'A*C', 'B*C']).
keys (list of strings) The names of all known semantic pointers (e.g., ['A', 'B', 'C']).
vector_pairs (ndarray) The values for each pair of semantic pointers, convolved together, in the same order as in key_pairs.
vectors (ndarray) All of the semantic pointer values in a matrix, in the same order as in keys.
create_pointer(attempts=100, unitary=False)[source]

Create a new semantic pointer.

This will take into account the randomize and max_similarity parameters from self. If a pointer satisfying max_similarity is not generated after the specified number of attempts, the candidate pointer with lowest maximum cosine with all existing pointers is returned.

add(key, p)[source]

Add a new semantic pointer to the vocabulary.

The pointer value can be a SemanticPointer or a vector.

parse(text)[source]

Evaluate a text string and return the corresponding SemanticPointer.

This uses the Python eval() function, so any Python operators that have been defined for SemanticPointers are valid (+, -, *, ~, ()). Any terms do not exist in the vocabulary will be automatically generated. Valid semantic pointer terms must start with a capital letter.

If the expression returns a scalar (int or float), a scaled version of the identity SemanticPointer will be returned.

identity

Return the identity vector.

text(v, minimum_count=1, maximum_count=None, threshold=0.1, join=';', terms=None, normalize=False)[source]

Return a human-readable text version of the provided vector.

This is meant to give a quick text version of a vector for display purposes. To do this, compute the dot product between the vector and all the terms in the vocabulary. The top few vectors are chosen for inclusion in the text. It will try to only return terms with a match above the threshold, but will always return at least minimum_count and at most maximum_count terms. Terms are sorted from most to least similar.

Parameters:

v : SemanticPointer or ndarray

The vector to convert into text.

minimum_count : int, optional (Default: 1)

Always return at least this many terms in the text.

maximum_count : int, optional (Default: None)

Never return more than this many terms in the text. If None, all terms will be returned.

threshold : float, optional (Default: 0.1)

How small a similarity for a term to be ignored.

join : str, optional (Default: ‘;’)

The text separator to use between terms.

terms : list, optional (Default: None)

Only consider terms in this list of strings.

normalize : bool, optional (Default: False)

Whether to normalize the vector before computing similarity.

dot(v)[source]

Returns the dot product with all terms in the Vocabulary.

Input parameter can either be a SemanticPointer or a vector.

dot_pairs(v)[source]

Returns the dot product with all pairs of terms in the Vocabulary.

Input parameter can either be a SemanticPointer or a vector.

transform_to(other, keys=None)[source]

Create a linear transform from one Vocabulary to another.

This is simply the sum of the outer products of the corresponding terms in each Vocabulary.

Parameters:

other : Vocabulary

The other vocabulary to translate into.

keys : list, optional (Default: None)

If None, any term that exists in just one of the Vocabularies will be created in the other Vocabulary and included. Otherwise, the transformation will only consider terms in this list. Any terms in this list that do not exist in the Vocabularies will be created.

prob_cleanup(similarity, vocab_size, steps=10000)[source]

Estimate the chance of successful cleanup.

This returns the chance that, out of vocab_size randomly chosen vectors, at least one of them will be closer to a particular vector than the value given by compare. To use this, compare your noisy vector with the ideal vector, pass that value in as the similarity parameter, and set vocab_size to be the number of competing vectors.

The steps parameter sets the accuracy of the approximate integral needed to compute this.

The basic principle used here is that the probability of two random vectors in a D-dimensional space being a given angle apart is proportional to sin(angle)**(D-2). So we integrate this value to get a probability of one vector being farther away than the desired angle, and then raise that to vocab_size to get the probability that all of them are farther away.

extend(keys, unitary=False)[source]

Extends the vocabulary with additional keys.

Creates and adds the semantic pointers listed in keys to the vocabulary.

Parameters:

keys : list

List of semantic pointer names to be added to the vocabulary.

unitary : bool or list, optional (Default: False)

If True, all generated pointers will be unitary. If a list of strings, any pointer whose name is on the list will be forced to be unitary when created.

create_subset(keys)[source]

Returns the subset of this vocabulary.

Creates and returns a subset of the current vocabulary that contains all the semantic pointers found in keys.

Parameters:

keys : list

List of semantic pointer names to be copied over to the new vocabulary.

nengo.spa.similarity(data, vocab, normalize=False)[source]

Return the similarity between some data and the vocabulary.

Computes the dot products between all data vectors and each vocabulary vector. If normalize=True, normalizes all vectors to compute the cosine similarity.

Parameters:

data: array_like

The data used for comparison.

vocab: Vocabulary or array_like

Vocabulary (or list of vectors) to use to calculate the similarity values.

normalize : bool, optional (Default: False)

Whether to normalize all vectors, to compute the cosine similarity.

The action language

class nengo.spa.Actions(*args, **kwargs)[source]

A collection of Action objects.

The *args and **kwargs are treated as unnamed and named actions, respectively. The list of actions are only generated once process is called, since it needs access to the list of module inputs and outputs from the SPA object. The **kwargs are sorted alphabetically before being processed.

count

Return the number of actions.

process(spa)[source]

Parse the actions and generate the list of Action objects.

class nengo.spa.actions.Action(sources, sinks, action, name)[source]

A single action.

Consists of a conditional Expression (optional) and an Effect.

Parameters:

sources : list

The names of valid sources of information (SPA module outputs).

sinks : list

The names of valid places to send information (SPA module inputs).

action : str

A string defining the action. If '-->' is in the string, this is used as a marker to split the string into condition and effect. Otherwise it is treated as having no condition and just effect.

name : str

The name of this action.

class nengo.spa.actions.Expression(sources, expression)[source]

Parses an Action expression given a set of module outputs.

Parameters:

sources : list

The names of the module outputs that can be used as part of the expression.

expression : str

The expression to evaluate. This either defines the utility of the action, or a value from an effect’s assignment, given the state information from the module outputs. The simplest expression is "1" and they can get more complex, such as "0.5*(dot(vision, DOG) + dot(memory, CAT*MOUSE)*3 - 1)".

class nengo.spa.actions.Effect(sources, sinks, effect)[source]

Parses an action effect given a set of module outputs.

The following, in an Action string, are valid effects:

"motor=A"
"motor=A*B, memory=vision+DOG"
"motor=0.5*(memory*A + vision*B)"
Parameters:

sources : list

The names of valid sources of information (SPA module outputs).

sinks : list

The names of valid places to send information (SPA module inputs).

effect: str

The action to implement. This is a set of assignment statements which can be parsed into a VectorList.

class nengo.spa.action_objects.Symbol(symbol)[source]

A set of semantic pointer symbols and associated math.

This is an abstract semantic pointer (not associated with a particular vocabulary or dimension). It is just meant for keeping track of the desired manipulations until such time as it is parsed with a particular Vocabulary.

Its contents are a single string, and this string is manipulated via standard mathematical operators (+ - * ~) for SemanticPointers. The result will always be able to be passed to Vocabulary.parse to get a valid SemanticPointer.

This is used by the spa.Actions parsing system.

class nengo.spa.action_objects.Source(name, transform=<nengo.spa.action_objects.Symbol object>, inverted=False)[source]

A particular source of a vector for the action system.

This will always refer to a particular named output from a spa.module.Module. It also tracks a single Symbol which represents a desired transformation from that output. For example, Source('vision') * Symbol('VISION') will result in a Source object for 'vision', but with transform set to the Symbol('VISION').

This is used by the spa.Actions parsing system.

class nengo.spa.action_objects.DotProduct(item1, item2, scale=1.0)[source]

The dot product of a Source and a Source or a Source and a Symbol.

This represents a similarity measure for computing the utility of an action. It also maintains a scaling factor on the result, so that the 0.5 in "0.5*DotProduct(Source('vision'), Symbol('DOG'))" can be correctly tracked.

This class is meant to be used with an eval-based parsing system in the Condition class, so that the above DotProduct can also be created with "0.5*dot(vision, 'DOG')".

class nengo.spa.action_objects.Convolution(source1, source2, transform=<nengo.spa.action_objects.Symbol object>)[source]

The convolution of two sources together.

class nengo.spa.action_objects.Summation(items)[source]

A summation over all subexpressions.

SPA modules

class nengo.spa.module.Module(label=None, seed=None, add_to_container=None)[source]

Base class for SPA Modules.

Modules are networks that also have a list of inputs and outputs, each with an associated Vocabulary (or a desired dimensionality for the vocabulary).

The inputs and outputs are dictionaries that map a name to an (object, Vocabulary) pair. The object can be a Node or an Ensemble.

on_add(spa)[source]

Called when this is assigned to a variable in the SPA network.

Overload this when you want processing to be delayed until after the module is attached to the SPA network. This is usually for modules that connect to other things in the SPA model (such as the basal ganglia or thalamus).

class nengo.spa.AssociativeMemory(input_vocab, output_vocab=None, input_keys=None, output_keys=None, default_output_key=None, threshold=0.3, inhibitable=False, wta_output=False, wta_inhibit_scale=3.0, wta_synapse=0.005, threshold_output=False, label=None, seed=None, add_to_container=None)[source]

Associative memory module.

See Associative Memory example for an introduction and examples.

Parameters:

input_vocab: list or Vocabulary

The vocabulary (or list of vectors) to match.

output_vocab: list or Vocabulary, optional (Default: None)

The vocabulary (or list of vectors) to be produced for each match. If None, the associative memory will act like an autoassociative memory (cleanup memory).

input_keys : list, optional (Default: None)

A list of strings that correspond to the input vectors.

output_keys : list, optional (Default: None)

A list of strings that correspond to the output vectors.

default_output_key: str, optional (Default: None)

The semantic pointer string to be produced if the input value matches none of vectors in the input vector list.

threshold: float, optional (Default: 0.3)

The association activation threshold.

inhibitable: bool, optional (Default: False)

Flag to indicate if the entire associative memory module is inhibitable (i.e., the entire module can be inhibited).

wta_output: bool, optional (Default: False)

Flag to indicate if output of the associative memory should contain more than one vector. If True, only one vector’s output will be produced; i.e. produce a winner-take-all (WTA) output. If False, combinations of vectors will be produced.

wta_inhibit_scale: float, optional (Default: 3.0)

Scaling factor on the winner-take-all (WTA) inhibitory connections.

wta_synapse: float, optional (Default: 0.005)

Synapse to use for the winner-take-all (wta) inhibitory connections.

threshold_output: bool, optional (Default: False)

Adds a threholded output if True.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

class nengo.spa.BasalGanglia(actions, input_synapse=0.002, label=None, seed=None, add_to_container=None)[source]

A basal ganglia, performing action selection on a set of given actions.

See networks.BasalGanglia for more details.

Parameters:

actions : Actions

The actions to choose between.

input_synapse : float, optional (Default: 0.002)

The synaptic filter on all input connections.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

bias

Create a bias node, when needed.

on_add(spa)[source]

Form the connections into the BG to compute the utilty values.

Each action’s condition variable contains the set of computations needed for that action’s utility value, which is the input to the basal ganglia.

add_bias_input(index, value)[source]

Make an input that is just a fixed scalar value.

Parameters:

index : int

the index of the action

value : float or int

the fixed utility value to add

add_compare_input(index, source1, source2, scale)[source]

Make an input that is the dot product of two different sources.

This would be used for an input action such as dot(vision, memory). Each source might be transformed before being compared. If the two sources have different vocabularies, we use the vocabulary of the first one for comparison.

Parameters:

index : int

The index of the action.

source1 : Source

The first module output to read from.

source2 : Source

The second module output to read from.

scale : float

A scaling factor to be applied to the result.

add_dot_input(index, source, symbol, scale)[source]

Make an input that is the dot product of a Source and a Symbol.

This would be used for an input action such as dot(vision, A). The source may have a transformation applied first.

Parameters:

index : int

The index of the action.

source : Source

The module output to read from.

symbol : Source

The semantic pointer to compute the dot product with.

scale : float

A scaling factor to be applied to the result.

add_scalar_input(index, source)[source]

Add a scalar input that will vary over time.

This is used for the ouput of the Compare module.

Parameters:

index : int

The index of the action.

source : Source

The module output to read from.

class nengo.spa.Bind(dimensions, vocab=None, n_neurons=200, invert_a=False, invert_b=False, input_magnitude=1.0, label=None, seed=None, add_to_container=None)[source]

A module for binding together two inputs.

Binding is done with circular convolution. For more details on how this is computed, see the underlying CircularConvolution network.

Parameters:

dimensions : int

Number of dimensions for the two vectors to be compared.

vocab : Vocabulary, optional (Default: None)

The vocabulary to use to interpret the vectors. If None, the default vocabulary for the given dimensionality is used.

n_neurons : int, optional (Default: 200)

Number of neurons to use in each product computation.

invert_a, invert_b : bool, optional (Default: False, False)

Whether to reverse the order of elements in either the first input (invert_a) or the second input (invert_b). Flipping the second input will make the network perform circular correlation instead of circular convolution.

input_magnitude : float, optional (Default: 1.0)

The expected magnitude of the vectors to be convolved. This value is used to determine the radius of the ensembles computing the element-wise product.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

class nengo.spa.Buffer(dimensions, subdimensions=16, neurons_per_dimension=50, vocab=None, direct=False, label=None, seed=None, add_to_container=None)[source]

A module capable of representing a single vector, with no memory.

This is a minimal SPA module, useful for passing data along (for example, visual input).

Note

Deprecated in Nengo 2.1.0. Use spa.State instead.

Parameters:

dimensions : int

Number of dimensions for the vector.

subdimensions : int, optional (Default: 16)

Size of the individual ensembles making up the vector. Must divide dimensions evenly.

neurons_per_dimensions : int, optional (Default: 50)

Number of neurons in an ensemble will be neurons_per_dimensions * subdimensions.

vocab : Vocabulary, optional (Default: None)

The vocabulary to use to interpret the vector. If None, the default vocabulary for the given dimensionality is used.

direct : bool, optional (Default: False)

Whether or not to use direct mode for the neurons.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

class nengo.spa.Compare(dimensions, vocab=None, neurons_per_multiply=200, input_magnitude=1.0, label=None, seed=None, add_to_container=None)[source]

A module for computing the dot product of two inputs.

Parameters:

dimensions : int

Number of dimensions for the two vectors to be compared.

vocab : Vocabulary, optional (Default: None)

The vocabulary to use to interpret the vector. If None, the default vocabulary for the given dimensionality is used.

neurons_per_multiply : int, optional (Default: 200)

Number of neurons to use in each product computation.

input_magnitude : float, optional (Default: 1.0)

The expected magnitude of the vectors to be multiplied. This value is used to determine the radius of the ensembles computing the element-wise product.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

class nengo.spa.Cortical(actions, synapse=0.01, neurons_cconv=200, label=None, seed=None, add_to_container=None)[source]

A SPA module for forming connections between other modules.

Parameters:

actions : Actions

The actions to implement.

synapse : float, optional (Default: 0.01)

The synaptic filter to use for the connections.

neurons_cconv : int, optional (Default: 200)

Number of neurons per circular convolution dimension.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

add_direct_effect(target_name, value)[source]

Make a fixed constant input to a module.

Parameters:

target_name : str

The name of the module input to use.

value : str

A semantic pointer to be sent to the module input.

add_route_effect(target_name, source_name, transform, inverted)[source]

Connect a module output to a module input.

Parameters:

target_name : str

The name of the module input to effect.

source_name : str

The name of the module output to read from. If this output uses a different vocabulary than the target, a linear transform will be applied to convert from one to the other.

transform : str

A semantic pointer to convolve with the source value before sending it into the target. This transform takes place in the source vocabulary.

inverted : bool

Whether to invert the transform.

add_conv_effect(target_name, effect)[source]

Convolve the output of two modules and send result to target.

Parameters:

target_name : str

The name of the module input to affect

effect : Convolution

The details of the convolution to implement.

class nengo.spa.Input(label=None, seed=None, add_to_container=None, **kwargs)[source]

A SPA module for providing external inputs to other modules.

The parameters passed to this module indicate the module input name and the function to execute to generate inputs to that module. The functions should always return strings, which will then be parsed by the relevant vocabulary. For example:

def input1(t):
    if t < 0.1:
        return 'A'
    else:
        return '0'

spa_net.input = spa.Input(vision=input1, task='X')

will create two inputs:

  1. an input to the vision module, which for the first 0.1 seconds is the value associated with the 'A' semantic pointer and then a vector of all zeros, and
  2. an input to the task module which is always the value associated with the 'X' semantic pointer.
Parameters:

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

on_add(spa)[source]

Create the connections and nodes.

class nengo.spa.Memory(dimensions, subdimensions=16, neurons_per_dimension=50, synapse=0.01, vocab=None, tau=None, direct=False, label=None, seed=None, add_to_container=None)[source]

A SPA module capable of storing a vector over time.

Parameters are the same as spa.Buffer, with the addition of synapse and tau.

Note

Deprecated in Nengo 2.1.0. Use spa.State instead.

Parameters:

dimensions : int

Number of dimensions for the vector.

subdimensions : int, optional (Default: 16)

Size of the individual ensembles making up the vector. Must divide dimensions evenly.

neurons_per_dimensions : int, optional (Default: 50)

Number of neurons in an ensemble will be neurons_per_dimensions * subdimensions.

synapse : float, optional (Default: 0.01)

Synaptic filter to use on recurrent connection.

vocab : Vocabulary, optional (Default: None)

The vocabulary to use to interpret the vector. If None, the default vocabulary for the given dimensionality is used.

tau : float or None, optional (Default: None)

Effective time constant of the integrator. If None, it should have an infinite time constant.

direct : bool, optional (Default: False)

Whether or not to use direct mode for the neurons.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

class nengo.spa.State(dimensions, subdimensions=16, neurons_per_dimension=50, feedback=0.0, feedback_synapse=0.1, vocab=None, label=None, seed=None, add_to_container=None)[source]

A module capable of representing a single vector, with optional memory.

This is a minimal SPA module, useful for passing data along (for example, visual input).

Parameters:

dimensions : int

Number of dimensions for the vector.

subdimensions : int, optional (Default: 16)

Size of the individual ensembles making up the vector. Must divide dimensions evenly.

neurons_per_dimensions : int, optional (Default: 50)

Number of neurons in an ensemble will be neurons_per_dimensions * subdimensions.

feedback : float, optional (Default: 0.0)

Gain of feedback connection. Set to 1.0 for perfect memory, or 0.0 for no memory. Values in between will create a decaying memory.

feedback_synapse : float, optional (Default: 0.1)

The synapse on the feedback connection.

vocab : Vocabulary, optional (Default: None)

The vocabulary to use to interpret the vector. If None, the default vocabulary for the given dimensionality is used.

tau : float or None, optional (Default: None)

Effective time constant of the integrator. If None, it should have an infinite time constant.

direct : bool, optional (Default: False)

Whether or not to use direct mode for the neurons.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

class nengo.spa.Thalamus(bg, neurons_action=50, threshold_action=0.2, mutual_inhibit=1.0, route_inhibit=3.0, synapse_inhibit=0.008, synapse_bg=0.008, synapse_direct=0.01, neurons_channel_dim=50, subdim_channel=16, synapse_channel=0.01, neurons_cconv=200, neurons_gate=40, threshold_gate=0.3, synapse_to_gate=0.002, label=None, seed=None, add_to_container=None)[source]

A thalamus, implementing the effects for an associated basal ganglia.

See spa.BasalGanglia for information on the basal ganglia, and networks.Thalamus for details on the underlying network.

Parameters:

bg : spa.BasalGanglia

The associated basal ganglia that defines the action to implement.

neurons_action : int, optional (Default: 50)

Number of neurons per action to represent the selection.

threshold_action : float, optional (Default: 0.2)

Minimum value for action representation.

mutual_inhibit : float, optional (Default: 1.0)

Strength of inhibition between actions.

route_inhibit : float, optional (Default: 3.0)

Strength of inhibition for unchosen actions.

synapse_inhibit : float, optional (Default: 0.008)

Synaptic filter to apply for inhibition between actions.

synapse_bg : float, optional (Default: 0.008)

Synaptic filter for connection between basal ganglia and thalamus.

synapse_direct : float, optional (Default: 0.01)

Synaptic filter for direct outputs.

neurons_channel_dim : int, optional (Default: 50)

Number of neurons per routing channel dimension.

subdim_channel : int, optional (Default: 16)

Number of subdimensions used in routing channel.

synapse_channel : float, optional (Default: 0.01)

Synaptic filter for channel inputs and outputs.

neurons_cconv : int, optional (Default: 200)

Number of neurons per circular convolution dimension.

neurons_gate : int, optional (Default: 40)

Number of neurons per gate.

threshold_gate : float, optional (Default: 0.3)

Minimum value for gating neurons.

synapse_to-gate : float, optional (Default: 0.002)

Synaptic filter for controlling a gate.

label : str, optional (Default: None)

A name for the ensemble. Used for debugging and visualization.

seed : int, optional (Default: None)

The seed used for random number generation.

add_to_container : bool, optional (Default: None)

Determines if this Network will be added to the current container. If None, will be true if currently within a Network.

add_direct_effect(index, target_name, value)[source]

Cause an action to drive a particular module input to value.

Parameters:

index : int

The action number that causes this effect.

target_name : str

The name of the module input to connect to.

value : str

A semantic pointer to be sent into the module when this action is active.

get_gate(index, target_name)[source]

Return the gate for an action.

The gate will be created if it does not already exist. The gate neurons have no activity when the action is selected, but are active when the action is not selected. This makes the gate useful for inhibiting ensembles that should only be active when this action is active.

add_route_effect(index, target_name, source_name, transform, inverted)[source]

Set an action to send source to target with the given transform.

Parameters:

index : int

The action number that will cause this effect.

target_name : str

The name of the module input to affect.

source_name : str

The name of the module output to read from. If this output uses a different Vocabulary than the target, a linear transform will be applied to convert from one to the other.

transform : str

A semantic point to convolve with the source value before sending it into the target. This transform takes place in the source Vocabulary.

inverted : bool

Whether to perform inverse convolution on the source.

add_conv_effect(index, target_name, effect)[source]

Set an action to combine two sources and send to target.

Parameters:

index : int

The action number that will cause this effect.

target_name : str

The name of the module input to affect.

effect : Convolution

The details of the convolution to implement.