# How is a spike represented as current in a neuron to neuron connection when sending spikes to Loihi?

Let’s say I have an ensemble A running on my CPU, and ensemble B running on Loihi, both with the same number of neurons.

``````input = nengo.Node(output=pass_through_function, size_in=0, size_out=11)

A = nengo.Ensemble(n_neurons=512, dimensions=1,neuron_type=nengo.LIF())

self.network.config[A].on_chip = False

B = nengo.Ensemble(n_neurons=512, dimensions=1, neuron_type=nengo.LIF())

conn_in_A  = nengo.Connection(input, A.neurons,  synapse=None, transform=<512 x 11 numpy array>)
conn_A_B  = nengo.Connection(A.neurons, B.neurons, synapse=None,  transform=<512x512 identity matrix>)
``````

Because I am doing a direct connection between neurons, the transforms matrices I apply will act on the input, and the input is treated as current. However, what happens if neuron i in A spikes- Is a current of 1/dt sent to B, to force the same neuron i to spike there also?

Let’s say we add another ensemble C running on Loihi and connect C.neurons to B.neurons with some 512x512 transformation matrix. Will the current from C add to the current from A (assuming the spike is sent as current)?

More generally, I guess I’m confused about the relationship between current and spikes when running ensembles on Loihi.

The reason I have this setup is because Loihi only takes spikes as input, and this off-chip implementation is similar to the Nengo Loihi tutorials I found online.

Keshav

Hi @kshivvy, and welcome back to the Nengo forums.

In Nengo a spike is a single timestep event with a magnitude of 1/dt. If you make a connection from a `.neurons` object, the resulting current fed to the post object depends on the synaptic filter applied on the connection. If the synapse is `None` or `0`, then no change to the spike is applied, and what is essentially a 1/dt single timestep spike of current is set to the post population. If a synapse is specified, the spike is convolved with the synapse, and that resulting current is sent to the post population (over time).

Whether or not the post population neuron spikes depends on the transformation weight on the connection, and the spiking threshold for the post neuron. With the default transformation weight (of 1), a spike should cause a spike in the post neuron.

Yes. With multiple inputs to a neuron, the input current will be added. In the case where no synapses are used on the connection, then the spikes are just treated as current.

When connecting directly to the `.neurons` objects, the behaviour of a Nengo network in NengoLoihi is identical to what would happen in regular Nengo, so you can experiment with the network in regular Nengo. Alternatively, you can also create the NengoLoihi simulator object in `target="sim"` mode, which will “emulate” the neuron spiking behaviour on your CPU.

Here’s a test script that I created for my own testing:
test_neuron_direct_conn.py (1.0 KB)

I should note that the behaviour described above where an input spike elicits an output spike is dependent on the neuron type used. In the case of your code, the LIF neuron spikes a maximum of once per timestep. For neurons that spike more than once per timestep (e.g., the `SpikingRectifiedLinear` neuron), one input spike can cause multiple output spikes to occur, and you’ll need to tweak the connection transform appropriately.