gpt4 book ai didi

python - 使用 PyNN 发送尖峰时出错 - SpiNNaker

转载 作者:行者123 更新时间:2023-12-04 09:27:18 26 4
gpt4 key购买 nike

我正在尝试向我使用 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 代码中的部分,以了解它为什么不起作用并且没有找到任何可能导致此问题的东西。世界“注入(inject)器”和我尝试过的任何其他词都在字典中用作键。其余的示例脚本工作正常。
任何提示appriaciated。谢谢

最佳答案

我正在发布我找到的答案,以防其他人遇到同样的问题
输出没有写入数据库;这可以通过将“create_database = True”添加到 .spynnaker.cfg 文件的“[Database]”部分来强制执行。

关于python - 使用 PyNN 发送尖峰时出错 - SpiNNaker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62959896/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com