I am trying to send a single spike to neuron 18 of the population I created using connection.send_spike(label, 18). The code I am using is the same as the example on Jypiter which runs correctly there.
# Import the simulator
import pyNN.spiNNaker as sim
# Other imports used in this example
from time import sleep
# Set up a function that will start sending spikes when the simulation starts.
# This is automatically run in a separate thread from the rest of the simulation.
# This must accept two arguments:
# The label of the Population that the callback is registered against,
# and the connection the callback is registered against.
def send_spikes(label, connection):
# Sleep to make sure everything is fully ready
sleep(0.01)
# Send a spike to neuron 0
connection.send_spike(label, 0)
# Send spikes to neurons 1-4 after 0.1ms
sleep(0.1)
connection.send_spikes(label, range(1, 5))
# Keep track of the label of the injector as this needs to match up in several places
injector_label = "injector"
# Create the connection, noting that the label will be a "sender".
# Note the use of local_port=None allows the automatic assignment of a port.
connection = sim.external_devices.SpynnakerLiveSpikesConnection(
local_port=None, send_labels=[injector_label])
# Add a callback to be called at the start of the simulation
connection.add_start_resume_callback(injector_label, send_spikes)
# Set up the simulation itself
sim.setup(1.0,1.0,10.0)
# Set up the injector population with 5 neurons,
# simultaneously registering the connection as a listener
injector = sim.Population(
5, sim.external_devices.SpikeInjector(
database_notify_port_num=connection.local_port),
# Critical: Make sure the label is used!
label=injector_label)
# Set up a Population to receive spikes and record
pop = sim.Population(5, sim.IF_curr_exp(), label="pop")
pop.record("spikes")
# Connect the injector to the population
sim.Projection(injector, pop, sim.OneToOneConnector(), sim.StaticSynapse(weight=5))
# Run the simulation and get the spikes out
sim.run(1000)
spikes = pop.get_data("spikes").segments[0].spiketrains
# End the simulation and display the spikes
sim.end()
print(spikes)
However I am receiving the following error:
Traceback (most recent call last):
File "/home/costis/anaconda3/envs/spynslam/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/costis/anaconda3/envs/spynslam/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "<ipython-input-2-9fba9de17725>", line 18, in send_spikes
connection.send_spike(label, 0)
File "/home/costis/anaconda3/envs/spynslam/lib/python3.6/site-packages/spynnaker/pyNN/connections/spynnaker_live_spikes_connection.py", line 69, in send_spike
self.send_spikes(label, [neuron_id], send_full_keys)
File "/home/costis/anaconda3/envs/spynslam/lib/python3.6/site-packages/spynnaker/pyNN/connections/spynnaker_live_spikes_connection.py", line 84, in send_spikes
self.send_events(label, neuron_ids, send_full_keys)
File "/home/costis/anaconda3/envs/spynslam/lib/python3.6/site-packages/spinn_front_end_common/utilities/connections/live_event_connection.py", line 504, in send_events
x, y, p, ip_address = self.__send_address_details[label]
KeyError: 'injector'
I searched the parts in the PyNN code as well in order to understand why it is not working and did not find anything that could lead to this problem. The world 'injector' and any other word I tried is being used in a dictionary as a key. The rest of the example scripts are working fine.
Any tips appriaciated. Thank you