Hello everyone:

I know this may sound weird,

but I’m trying to apply PES online learning rule on ensemble (or EnsembleArray) to learn the association of the SPs.

e.g: feed pointer ‘A’ into an ensemble and output pointer ‘B’.

Then I found out that this problem involves different levels in Nengo, SPA and network level.

So I’ve got a hard time on figuring out how to integrate two.

Finally, I did managed to run the sim in GUI.

But doesn’t work as I expected.

I’ll update the simulation result later. --DONE

the code is as below:

`# Setup the environment`

import numpy as np

import nengo

import nengo.spa as spa

from nengo.spa import Vocabulary

from nengo.spa import BasalGanglia

from nengo.spa import Thalamus

from nengo.dists import Uniform

dim=16 # Number of dimensions

N=32 # Neurons per dimension

N_conv=64 # Number of neurons per dimension in bind/unbind populations

N_mem=32 # Number of neurons per dimension in memory population

ZERO=[0]*dim # Defining a zero vector having length equal to the number of

# dimensions`#Creating the vocabulary`

rng = np.random.RandomState(15)

vocab = Vocabulary(dimensions=dim, rng=rng, max_similarity=0.05)

TOM = vocab.parse(‘TOM’)

ALICE = vocab.parse(‘ALICE’)

JOHN = vocab.parse(‘JOHN’)

EDWARD = vocab.parse(‘EDWARD’)

START = vocab.parse(‘START’)

ZERO=vocab.add(‘ZERO’, [0]*dim)

model = spa.SPA(label=‘Online Learning of Sequences in LTM’, vocabs=[vocab])

with model:`def visual_input(t): if 0.1 < t < 0.25: return 'TOM' elif 0.3 < t < 0.45: return 'ALICE' elif 0.5 < t < 0.65: return 'JOHN' elif 0.7 < t < 0.85: return 'EDWARD' elif 1.1 < t < 1.25: return 'TOM' elif 1.3 < t < 1.45: return 'ALICE' elif 1.5 < t < 1.65: return 'JOHN' elif 1.7 < t < 1.85: return 'EDWARD' else: return 'ZERO' model.visual = spa.State(dim) model.input = spa.Input(visual=visual_input) def visual_input2(t): if 0.1 < t < 0.25: return 'ALICE' elif 0.3 < t < 0.45: return 'JOHN' elif 0.5 < t < 0.65: return 'EDWARD' elif 0.7 < t < 0.85: return 'TOM' else: return 'ZERO' model.visual2 = spa.State(dim) model.input2 = spa.Input(visual2=visual_input2)`

`model.memory = nengo.networks.EnsembleArray(n_neurons=N, n_ensembles=dim) model.memory_out = nengo.networks.EnsembleArray(n_neurons=N, n_ensembles=dim) nengo.Connection(model.visual.output, model.memory.input) model.error = nengo.networks.EnsembleArray(n_neurons=N, n_ensembles=dim) model.learning_control = nengo.Node(output=lambda t: -1*int(t >= 1)) voja = nengo.Voja(post_tau=None, learning_rate=5e-2) model.conn_in = list() model.conn_out = list() for i in range(dim): # Learn the encoders/keys # model.conn_in.append( # nengo.Connection(model.memory_in.ensembles[i], model.memory.ensembles[i], # synapse=None, learning_rule_type=voja) # ) nengo.Connection(model.visual2.output[i], model.error.ensembles[i], transform=-1) nengo.Connection(model.memory_out.ensembles[i], model.error.ensembles[i], transform=+1) # Learn the decoders/values, initialized to a null function model.conn_out.append( nengo.Connection(model.memory.ensembles[i], model.memory_out.ensembles[i], learning_rule_type=nengo.PES(1e-3), function=lambda x: np.zeros(1)) ) nengo.Connection(model.error.ensembles[i], model.conn_out[i].learning_rule) nengo.Connection(model.learning_control, model.error.ensembles[i].neurons, transform=[[10]]*N)`

`model.test = spa.State(dim) nengo.Connection(model.memory_out.output, model.test.input)`

Sim results:

learning phase

verifying phase