SPA associative memory - Combining Vocabs & Parsing SPA keys


Hello all,

I have some queries on SPA associative memory usage.

I am trying to hook up multiple associative memories together, so that for example an output pointer from one memory is sent via a nengo.connection to another memory and transformed into something else via a heteroassociative rule.
This works fine when linking memories 1:1, thanks to the ability to choose input_vocab and output_vocab separately (with input_vocab set to the vocab of the source memory, and output_vocab set to the target memory).

Unfortunately I have not found a similarly simple way to hook up memories in a many-to-one fashion. Say there is Area A and Area B both projecting to Area C, and the heteroassociation rule in Area C looks like the following:
“A.1 + B.1 -> C.1”. To do this, I currently do the following:

  • make a new vocab called vocabAB and add to it all key/vectors from A and all key/vectors from B
  • set vocabAB as the input_vocab to memory C

Is there a better way to do this?

Likewise as shown above, C’s heteroassociative memory depends on 2 inputs. In the current API, SPA.AssociativeMemory’s input_keys argument cannot be set to ‘A + B’ for example. At present I do it by parsing the key “A + B” as so: normalize(input_vocab.parse(key).v), and then in the Spa.AssociativeMemory initializer’s call to AssocMem I set input_vectors directly instead of parsing input_keys. Is this the right approach?

The above methods I’m using seem to work but they seem like ‘hacks’ so I thought I would ask for some advice.



I assume you are not just adding each vector individually, but add up each A.i and B.i? I think that is how it needs to be done at the moment, but @tcstewar might now better.

I think it should be possible to use expressions like ‘A+B’ as input_keys. There might potentially be a bug here. Can you provide the code that you are using?

But if it doesn’t work, then the approach you described seems like the best thing to do to me.


Thanks for the reply! It appears I was on an old version of Nengo. input_keys does indeed accept ‘A+B’ now.

I am still working on the vocab issue.