LIF number of units when using nengo_dl.Layer?

I’m trying to build an AutoEncoder network for my research and now I’ve began tackling Nengo and NengoDL. In Tensorflow I would choose how many units I want in a given Layer like so:

x = Dense(units=32, activation='relu')(i)

In NengoDL I want to use LIF neurons, otherwise there’s not much reason in doing so. Adding a nengo_dl.Layer here is a bit cloudy for me as I don’t really got the idea of what’s happening in the following line of code:

x = nengo_dl.Layer(nengo.LIF(amplitude=0.01))(i)

Ideally I want to reproduce the same topology of my previous network, but I’m not sure of how many neurons are being created in these layers. Is it only one? Is it 100?
Is there a way for me to know this and better, to control this number?

Hi @Kinteshi, and welcome back to the Nengo forums. :smiley:

I believe that for the specific code in question, NengoDL would create a layer of LIF neurons where the number of neurons is determined by the output dimensionality of the preceding layer (in the case of your code, that would be the output shape of layer i).

To be more precise though, the number of neurons in the nengo.LIF layer is determined by the connection weight between layer i and x. For example, this code:

i = nengo.Node(np.zeros(10))
x = nengo_dl.Layer(nengo.LIF())(i, transform=np.random.random((100, 10)))

would create a layer x with 100 neurons, since the transformation matrix takes the 10 dimensional output of i, and transforms it into 100 dimensions (through the use of the matrix multiplication).

If you want to explicitly specify how many neurons to use in the x layer, you can also create the layer as a nengo.Ensemble. As an example, the following pieces of code are identical:

# Defining it as a nengo_dl.Layer
i = nengo.Node(np.zeros(10))  # Create i just to have some context
x = nengo_dl.Layer(nengo.LIF())(i)

and this:

# Defining it as a nengo.Ensemble
i = nengo.Node(np.zeros(10))  # Create i just to have some context
x = nengo.Ensemble(10, 1)  # Create an ensemble of 10 neurons
nengo.Connection(i, x.neurons)  # Create the connection between i and x
1 Like