Employing a lambda function on a connection

Dear Colleagues,

I am implementing an inhibitory network to model the inhibitory control of a fruit fly. The project is inspired by Gattuso, H., et al. (2024). Inhibitory control of locomotor statistics in walking Drosophila, bioRxiv.

A “stop” inhibition ensemble, U3, is connected to a descending node ensemble U1.

I would like to inhibit ensemble, U1, when the output of the stop inhibition ensemble, U3, is less than or equal to a certain threshold, 1e-2 in the code snippet below. If the output of U3 is larger than 1e-2, U1 is no longer inhibited.

I am familiar with lambda functions from java and this is and I have implemented the “logic” above on the connection from U3 to U1 as so:

c31 = nengo.Connection( U3, U1.neurons, function=lambda x: [-100] * U1.n_neurons if x <= 1e-2 else [1] * U1.n_neurons )

From the spiking activity and the values displayed in Nengo GUI I think it works but I have decided to ask the forum. Is this a reasonable implementation?

Thank you.

BU

Hello! I’m a bit late to answer this, but yes that is fine! I will note that I’ll often write that in a slightly different way though:

nengo.Connection(U3, U1.neurons, function=lambda x: -100 if x <= 1e-2 else 1,
                                 transform=np.ones((b.n_neurons, 1)))

This means exactly the same thing, as if you give both a function and a transform, it’ll do the function first and then the transform. So I like separating out the logic like this.

Also, I’ll note that all these versions also excite the neurons when x>1e-2. This may or may not be what you want. So you might try this:

nengo.Connection(U3, U1.neurons, function=lambda x: -100 if x <= 1e-2 else 0,
                                 transform=np.ones((b.n_neurons, 1)))

Finally, depending on the radius of the U1 population, you may not need -100 for the inhibition. The inhibition is scaled so that it’s in the same range as the radius of the post-synaptic population, so if the radius of U1 is 1 then you should be able to do this:

nengo.Connection(U3, U1.neurons, function=lambda x: -3 if x <= 1e-2 else 0,
                                 transform=np.ones((b.n_neurons, 1)))

(the biggest thing that’ll do is control how long the synapse is inhibited for after the input changes, which may or may not be important for you situation)

:slight_smile: Terry