Note

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

nengo_spa.operators

Operator-like SPA functions.

The operator functions work similar to other overloaded operators in Python. They call the class implementation on the operand, e.g. reinterpret(a, ...) calls a.reinterpret(...) like -a calls a.__neg__(). For binary operators, this will be tried for the left operand first. If the left operand does not have the corresponding method or if it returns NotImplemented, the same method prefixed with an r will be called on the right operand. For example, dot(a, b) tries a.dot(b) first and then b.rdot(a). This is equivalent to for example a + b trying a.__add__(b) first and then b.__radd__(a).

Functions

dot(a, b)

Dot-product between a and b.

reinterpret(source[, vocab])

Reinterpret source Semantic Pointer as part of vocabulary vocab.

translate(source, vocab[, populate, keys, …])

Translate source Semantic Pointer to vocabulary vocab.

nengo_spa.operators.dot(a, b)[source]

Dot-product between a and b.

nengo_spa.operators.reinterpret(source, vocab=None)[source]

Reinterpret source Semantic Pointer as part of vocabulary vocab.

The vocab parameter can be set to None to clear the associated vocabulary and allow the source to be interpreted as part of the vocabulary of any Semantic Pointer it is combined with.

nengo_spa.operators.translate(source, vocab, populate=None, keys=None, solver=None)[source]

Translate source Semantic Pointer to vocabulary vocab.

The translation of a Semantic Pointer uses some form of projection to convert the source Semantic Pointer to a Semantic Pointer of another vocabulary. By default the outer products of terms in the source and target vocabulary are used, but if solver is given, it is used to find a least squares solution for this projection.

Parameters
sourceobject

Source of Semantic Pointer.

vocabVocabulary

Target vocabulary.

populatebool, optional

Whether the target vocabulary should be populated with missing keys. This is done by default, but with a warning. Set this explicitly to True or False to silence the warning or raise an error.

keyslist, optional

All keys to translate. If None, all keys in the source vocabulary will be translated.

solvernengo.Solver, optional

If given, the solver will be used to solve the least squares problem to provide a better projection for the translation.