Nengolib Incompatability

Hi everyone,

I’m trying to create a program that requires nengolib. However, when I tried to install this package, pip would downgrade my nengo version from 3.2.0 to 2.8.0. This in turn broke other programs that work with Nengo FPGA that we have.
I wonder if there will be an update for nengolib soon that would work with the newest nengo version?

Thank you very much.

Murat Isik

1 Like

Hi @muratisik,

Unfortunately, despite the name, the nengolib package isn’t directly maintained by the Nengo development team. @arvoelke is the maintainer of the nengolib package, so you’ll need to contact him directly.

If you could let use know what you want to use from the nengolib package, perhaps we (the Nengo dev team) can suggest alternatives. :smiley:

Thank you for your interest @xchoo. I will contact him.

I am trying to implement and test this code (full-FORCE and “Classic FORCE” learning with spikes — nengolib 0.5.1 documentation).

Kind Regards
Murat

Have you tried using Nengo 3.2.0 and not using nengolib? I believe all of the features required by that notebook are available in the newest version of Nengo. e.g., nengo.RLS for the learning rule. The bandpass synapse is still awaiting review (https://github.com/nengo/nengo/pull/1650) but that is not critical to the FORCE learning setup, it’s merely a convenient way of generating some sample data.

In addition to @arvoelke’s suggestion, I have managed to figure out a workaround to get the notebook to work with very minimal changes. This would be useful to have some sort of starting point to convert the notebook to a fully native Nengo version.

Instructions:

  1. Clone and checkout the nengo3 branch of nengolib. This branch addresses the import statements that broke in nengolib when Nengo was update to v3:
git clone -b nengo3 https://github.com/arvoelke/nengolib
  1. Clone and checkout the nengolib-linearsystem branch of Nengo. This branch ports over most of the linear system stuff (synapses and filters, etc.) from nengolib into Nengo. As @arvoelke noted, this is just to get the bandpass synapse to work.
git clone -b nengolib-linearsystem https://github.com/nengo/nengo
  1. Create a Conda environment, then pip install the branched versions of nengolib and nengo:
cd <git_root>
pip install -e nengolib
pip install -e nengo
  1. Install the rest of the packages needed:
pip install jupyter matplotlib seaborn

To get the code to work, you’ll need to modify the notebook as well. I noticed that with the default learning rate (0.1) the system was super unstable. I dropped it down to 0.00001 and it seemed to do better. You can probably play around with the learning rate to tune the performance. I haven’t tried the built-in Nengo RLS rule myself, so you might have to tweak the learning rate for that too. One thing to note is that NengoFPGA only supports the PES learning rule, so you’ll need a way to reframe or reimplement the RLS rule as a PES learning rule (if that is at all possible).

Another thing you’ll need to modify in the notebook is to use the built-in Nengo bandpass synapse. To do this change this line:

nengo.Connection(u, z, synapse=nengolib.synapses.Bandpass(freq, decay))

to this:

nengo.Connection(u, z, synapse=nengo.synapses.Bandpass(freq, 1.0 / decay))

You’ll notice that the second function argument is different. If I am interpreting the documentation correctly, the nengolib bandpass synapse uses Q as the second function argument, whereas the Nengo bandpass synapse uses alpha as the second function argument. From the docs here, it states that alpha is the inverse of Q, thus the reciprocal.