Hi @joshivm22,
To start, if you are looking for a solution that is compatible with NengoLoihi, it’ll be better to implement this function using nengo.Ensemble
rather than nengo.Dense
.
Now, let us examine the function you want to implement:
$y(t) = W \times X(t) + f(y(t-1))$
Looking at this function, we first notice that it is similar to this simpler form:
$y(t) = X(t) + y(t-1)$
This is the formulation for a integrator, which is known to be implementable in Nengo (see this example for the basic code, and this example for the explanation on how the different weights are derived). An integrator is simply:
tau_fdbk = 0.1
with nengo.Network() as model:
in_node = nengo.Node(input_func)
ens = nengo.Ensemble(50, 1)
nengo.Connection(ens, ens, synapse=tau_fdbk)
nengo.Connection(in_node, ens, transform=tau_fdbk, synapse=tau_fdbk)
Now let’s start modifying the integrator to implement the function you want. First, we modify the input so that instead of just $X(t)$, it’s $W \times X(t)$. This can be done by simply changing the transform
matrix of the input connection to the integrator:
nengo.Connection(in_node, ens, transform=tau_fdbk * W, synapse=tau_fdbk)
As for the last part of the modification, we need to do $f(y(t-1))$ instead of just $y(t-1)$, but this is also a straightforward change to the integrator. To do this, we can simply define a function on the recurrent connection of the integrator:
nengo.Connection(ens, ens, synapse=tau_fdbk, function=f)
With both of these changes, the new implementation looks like:
tau_fdbk = 0.1
with nengo.Network() as model:
in_node = nengo.Node(input_func)
ens = nengo.Ensemble(50, 1)
nengo.Connection(ens, ens, synapse=tau_fdbk, function=f)
nengo.Connection(in_node, ens, transform=tau_fdbk * W, synapse=tau_fdbk)
Note that you’ll need to define the function f
and the weight W
separately in your code.