Hmm, looks like I have variables/ensembles/states and the semantic pointers mixed up? So then adding AGENT
, VERB
, and THEME
to the vocabulary of semantic pointers so that I am able to bind them, I can write something like this:
import nengo
import nengo.spa as spa
from nengo.spa import Vocabulary
import numpy as np
dim = 64
rng = np.random.RandomState(0)
vocab = Vocabulary(dimensions=dim, rng=rng)
BOY = vocab.parse('BOY')
DOG = vocab.parse('DOG')
CHASE = vocab.parse('CHASE')
HUG = vocab.parse('HUG')
AGENT = vocab.parse('AGENT')
VERB = vocab.parse('VERB')
THEME = vocab.parse('THEME')
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.out_agent = spa.State(dimensions=dim, label='out_agent')
model.out_verb = spa.State(dimensions=dim, label='out_verb')
model.out_theme = spa.State(dimensions=dim, label='out_theme')
actions = spa.Actions(
'p = VERB * CHASE + AGENT * DOG + THEME * BOY',
't = ~AGENT * THEME + ~CHASE * HUG + ~THEME * AGENT',
'z = p * t',
'out_agent = z * ~AGENT',
'out_verb = z * ~VERB',
'out_theme = z * ~THEME',
)
model.cortical = spa.Cortical(actions)
I’ve removed the input since it doesn’t seem applicable and reduced the dimensions to have it run faster.
Here should p
, t
, and z
be a semantic pointer as well (+ added to the vocab)? Or rather that does not matter since they’re simply holding the binded result as variables?
Also in the code above, the verb is still not the answer I expected (‘HUG’).