I am entirely new to nengo and SpikNNs. I was reading through the ‘How to Build a Brain’ book and I’m trying to replicate the Structured Manipulation (in Section 4.4) where it has the grammatical syntax and the semantic pointer P:
“The dog chases the boy”
P = verb * chase + agent * dog + theme * boy
In the example, it is manipulating the semantic pointer, P, without explicitly decoding each Pointer (verb/agent/theme) using the following semantic pointer:
T = ~agent * theme + ~chase * hug + ~theme * agent
such that the manipulation occurs:
T * P = verb * hug + agent * boy + theme * dog + noise
“The boy hugs the dog”
Notation-wise, to my understanding, * is used for circular convolution (HRR), and ~ is used for the inverse (book notation uses ’ ).
However, when implementing this in a similar manner to the examples, the verb (hug) appears to be incorrect when decoding the result. The code I used is below:
import nengo import nengo.spa as spa from nengo.spa import Vocabulary import numpy as np dim = 128 rng = np.random.RandomState(0) vocab = Vocabulary(dimensions=dim, rng=rng) # add semantic pointers to the vocabulary BOY = vocab.parse('BOY') DOG = vocab.parse('DOG') CHASE = vocab.parse('CHASE') HUG = vocab.parse('HUG') model = spa.SPA(label='Dog chases boy', vocabs=[vocab]) with model: model.P = spa.State(dimensions=dim, label='P') model.T = spa.State(dimensions=dim, label='T') model.Z = spa.State(dimensions=dim, label='Z') model.OutAgent = spa.State(dimensions=dim, label='OutAgent') model.OutVerb = spa.State(dimensions=dim, label='OutVerb') model.OutTheme = spa.State(dimensions=dim, label='OutTheme') model.agent = spa.State(dimensions=dim, label='agent') model.verb = spa.State(dimensions=dim, label='verb') model.theme = spa.State(dimensions=dim, label='theme') actions = spa.Actions( 'P = agent + verb + theme', 'T = ~agent * theme + ~CHASE * HUG + ~theme * agent', 'Z = T * P', 'OutAgent = Z * ~agent', 'OutVerb = Z * ~verb', 'OutTheme = Z * ~theme', ) model.cortical = spa.Cortical(actions) model.input = spa.Input(agent='DOG', verb='CHASE', theme='BOY')
I have several variations of this code and they end up with similar results. Is there something that I am missing or misunderstanding?