python - 使用 PyNN 发送尖峰时出错 - SpiNNaker
问题描述
我正在尝试向我使用 connection.send_spike(label, 18) 创建的群体中的第 18 个神经元发送一个峰值。我使用的代码与在 Jypiter 上正确运行的示例相同。
# 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)
但是我收到以下错误:
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'
我还搜索了 PyNN 代码中的部分,以了解它为什么不起作用并且没有找到任何可能导致此问题的内容。世界“注射器”和我尝试过的任何其他词都在字典中用作键。其余的示例脚本工作正常。
任何提示appriaciated。谢谢
解决方案
我正在发布我找到的答案,以防其他人遇到同样的问题
输出没有写入数据库;这可以通过将“create_database = True”添加到 .spynnaker.cfg 文件的“[Database]”部分来强制执行。
推荐阅读
- python - 我有两个模型 Chat 和 Message,我如何使用 Message 的 pub_date 订购 Chat?
- javascript - ExtJs - 动态改变面板的展开和折叠按钮
- python - 根据数组的子集填充列
- terminal - 在终端中打开文件夹
- node.js - 安装 Angular 不支持的引擎,OSX
- node.js - RabbitMQ 队列太大时出现 Elasticsearch 错误
- python - 使用Python从总和值递减的集合中查找组合(没有“大小= r”)
- mysql - (Django) DataFieldTime 总是返回 00:00:00.000000
- kubernetes - 将网站或域与 AKS 群集链接
- javascript - 如何通过模态传递变量?