How to implement VTB in nengo_spa.ActionSelection?

Hello.

I want to implement VTB(Vector-derived Transformation Matrix) binding in nengo_spa.ActionSelection.

In nengo_spa, * means CircularConvolution and *~ maens its inverse, not VTB.

So, for example, I want to realize like this:

import nengo
import nengo_spa as spa

dimensions = 64
vocab = spa.Vocabulary(dimensions=dimensions)

vocab.populate('FILLER; ROLE')

model = spa.Network(vocabs=[vocab])

with model:
    filler = nengo.Node(output=vocab['FILLER'].v)
    role = nengo.Node(output=vocab['ROLE'].v)

    # I want to accomplish like the code below
    bind = spa.networks.VTB(200, dimensions=dimensions)
    unbind = spa.networks.VTB(200, dimensions=dimensions, unbind_right=True)

    nengo.Connection(filler, bind.input_left)
    nengo.Connection(role, bind.input_right)
    nengo.Connection(bind.output, unbind.input_left), 
    
    with spa.ActionSelection() as action_sel:
        spa.ifmax(# <<similarity corresponding to the condition "UNBIND_withROLE">>,
            nengo.Connection(role.output, unbind.input_right)
            )
        spa.ifmax(0.3, ) 

In this example, the following error occurs:

nengo_spa.exceptions.SpaActionSelectionError: ifmax actions must be routing expressions like 'a >> b'.

What should I do?

That’s not strictly the case. In general, * and *~ just mean binding and unbinding. The particular algebra that it uses (e.g., circular convolution, versus VTB) depends on what algebra is passed to the Vocabulary that is being transformed. See: https://www.nengo.ai/nengo-spa/modules/nengo_spa.vocabulary.html#nengo_spa.vocabulary.Vocabulary

In particular, there is an algebra parameter that defaults to HRRs (circular convolution), but can also be nengo_spa.algebras.VtbAlgebra or even your own custom algebra.

See this example in the user guide for a demonstration of how a Vocabulary object can be initialized using the VTB algebra: https://www.nengo.ai/nengo-spa/user_guide/algebras.html

2 Likes

Thank you @arvoelke!