I want to learn the same function in two synapses that receive different inputs from different ensembles.
I have that simple code:
import nengo
import math
def my_secret_function(x):
return math.sin(x)
model = nengo.Network()
with model:
x = nengo.Node(lambda t: math.sin(t))
x_desired = nengo.Node(size_in=1)
x_pre = nengo.Ensemble(100, dimensions=1)
x_post = nengo.Ensemble(100, dimensions=1)
nengo.Connection(x, x_pre)
nengo.Connection(x, x_desired, function=my_secret_function)
conn = nengo.Connection(x_pre, x_post, learning_rule_type=nengo.PES(5e-4))
error = nengo.Node(size_in=1)
nengo.Connection(x_post, error)
nengo.Connection(x_desired, error, transform=-1)
nengo.Connection(error, conn.learning_rule)
Which generates the model:
This model receives x
and represent it in x_pre
, the x_desired
calculates the sinusoid of x
, thus the connection between x_pre
and x_post
learns to calculate sin(x)
(actually, in no time).
Now I want to use the same learnings (or function…) with other input, y
, that I control manually. So, I added:
y = nengo.Node([0])
y_pre = nengo.Ensemble(100, dimensions=1)
y_post = nengo.Ensemble(100, dimensions=1)
nengo.Connection(y, y_pre)
conn2 = nengo.Connection(y_pre, y_post, learning_rule_type=nengo.PES(5e-4))
nengo.Connection(error, conn2.learning_rule)
Which generates the model:
Unfortunately, as shown in the image above, when I set y=1
I don’t get the right answer. Actually, the connection between y_pre
and y_post
is moving as the connection between x_pre
and x_post
.
Is there a way to apply and reuse the learning from one synapse to another one, so they will represent the same function but with different inputs?