Spike train input to a SNN model


I am trying to build a spiking neural network model and my input data is already spike trains. Dose the model supports spike trains as input? (in the MNIST example the input is analog and not spikes)


I believe the spikes can be fed into an ensemble though the nengo.Ensemble().neurons property. However I’m not sure if the encoding/decoding would be optimized for the intended representation.

Maybe somebody can confirm this but that is my belief.


Thanks for the reply. I’m really new to the nengo, but shouldn’t the input go through a nengo.Node object? I guess nengo.Ensemble().neurons cannot get an input. Is it possible to change nengo.Node object to a spiking one?

Ah no worries. I’m still learning as well :slight_smile:

The nengo.Node() object provides a form of I/O to and from external sources. So I think in your case, you can take the spike train you want to use as input and have it within a nengo Node to output a one if it spikes and zero if it doesn’t. A simple example could be like:

import nengo

model = nengo.Network()

with model:
    input_node = nengo.Node([0]*10)             # output spike trains here (10 spike trains for 10 neurons)
    ens = nengo.Ensemble(10, 1)                 # ensemble of 10 neurons
    nengo.Connection(input_node, ens.neurons)   # connect node spike trains to ensemble spike trains

However, you will need to make sure the dt is aligned with the spike train you intend to pass into the ensemble and have the nengo.Node() output to generate your existing spike trains.


Sorry for the slow reply. You’re right that you’d want to use a Node to input the spike trains. One thing to keep in mind though is that with spike trains you probably want your Node output to be changing over time. With e.g. nengo.Node([0, 1, 0, 1]) the node is just outputting a constant vector of 1s and 0s. What we want is for that vector to change each timestep.

You could write your own Node function to do that, but one easy method is to use the built-in PresentInput process. This works like

with nengo.Network() as net:
    my_spikes = ...
    input_node = nengo.Node(nengo.processes.PresentInput(my_spikes, 0.001))

this is assuming that my_spikes is an array with shape (n_timesteps, n_neurons), where each entry is equal to 1/dt if the neuron spiked on that timestep and 0 otherwise. You may have to adjust your data to match that. The 0.001 is specifying the length of time that we want to present each row in my_spikes; you’d want to adjust that based on the dt in your data (keeping in mind also that the default nengo.Simulator dt is 0.001, so if you want to present spikes with a smaller dt than that you will need to decrease the simulator dt as well).

But assuming all that is set up appropriately with your data, the result will be that input_node will be outputting your spike trains. You can then connect input_node up to whatever other parts of your model you like.

1 Like