使用Brian2库时获取空白图

时间:2019-04-04 08:52:09

标签: python neural-network brian

我正在尝试为具有784个泊松输入的神经元绘制SpikeMonitor。但是我得到一个空白。为什么会发生这种情况,我该如何解决?

我尝试改变输入神经元的频率,也尝试改变输出神经元层中神经元的数量(而不是1)。但这没有帮助。

这是我的代码,带有适当的注释:

start_scope()
#a = spike_freqs_img_120*Hz
# Create group of 784 neurons which spike at 
# Poisson probability distributed time instances with given 1Hz frequency:
P = PoissonGroup(784, 1*Hz) 
# Weight for connection between neurons:
W = 5*siemens
# Equation followed by neuron behaviour:
eqs1 = '''dv/dt = -(v-El)/tau : volt'''
# Create a single neuron which behaves according to the above equation:
neuron = NeuronGroup(100, eqs1, threshold='v>Vt', reset='v=Vr', method='exact')
# Set initial voltage of the neuron:
neuron.v = Vr
# Define how the connections between neurons should be:
synapses = Synapses(P, neuron, 'w: siemens') 
synapses.connect()       # Make connections
synapses.w = W           # Set weight of connection    
M = SpikeMonitor(P)      # M stores the spike data of neurons in input
N = SpikeMonitor(neuron) # Similarly N stores for output neuron
run(1*second)            # run the simulation for 1 second
brian_plot(M)            # plot spikemonitor for input neurons
brian_plot(N)            # plot spikemonitor for output neuron

我得到的是brian_plot(M)的正确图形,但不是brian_plot(N)的正确图形。 brian_plot图不应为空白图。

1 个答案:

答案 0 :(得分:1)

SpikeMonitor是一个对象,它存储激发的神经元的时间(t)和索引(i)。 如果要绘制,则必须确定时间和索引轴。 您的代码中有一些错误。您尚未定义tau,Er和Vr,因此接收错误是合理的。

 brian_plot(M.t/ms, M.i)           
 brian_plot(N.t/ms, N.i)