Functions to examine data and vectors produced by SPA.
||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.|
similarity(data, vocab, normalize=False)¶
Return the similarity between simulation data and Semantic Pointers.
Computes the dot products between all Semantic Pointers in the Vocabulary and the simulation data for each timestep. If
normalize=True, normalizes all vectors to compute the cosine similarity.
- data ((D,) or (T, D) array_like) – The D-dimensional data for T timesteps used for comparison.
- vocab (Vocabulary or array_like) – Vocabulary (or list of vectors) used to calculate the similarity values.
- normalize (bool, optional) – Whether to normalize all vectors, to compute the cosine similarity.
Return expressions for all possible combinations to bind vocab’s keys.
>>> vocab = nengo_spa.Vocabulary(32) >>> vocab.populate('A; B; C') >>> sorted(pairs(vocab)) ['A*B', 'A*C', 'B*C']
text(v, vocab, minimum_count=1, maximum_count=None, threshold=0.1, join=';', terms=None, normalize=False)¶
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.
- v (SemanticPointer or array_like) – The vector to convert into text.
- minimum_count (int, optional) – Always return at least this many terms in the text.
- maximum_count (int, optional) – Never return more than this many terms in the text. If None, all terms will be returned.
- threshold (float, optional) – How small a similarity for a term to be ignored.
- join (str, optional) – The text separator to use between terms.
- terms (list, optional) – Only consider terms in this list of strings.
- normalize (bool) – Whether to normalize the vector before computing similarity.