在Brian2中定义子组(python中的库)

2024-06-16 17:29:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用Brian2在Python中测试一个脉冲神经网络。我收到这个错误:

 File "C:\ProgramData\Anaconda3\envs\snn\lib\site-packages\brian2\groups\group.py", line 393, in __getattr__
raise AttributeError('No attribute with name ' + name)

AttributeError:没有名为subgroup的属性

我的主要问题是生成GNeuronGroup)的子群。第一亚组为兴奋性神经元,第二亚组为抑制性神经元。你知道吗

G = NeuronGroup(4000, model=eqs, threshold=Vt, reset=Vr)

Ge = G.subgroup(3200) # Excitatory neurons

Gi = G.subgroup(800) # Inhibitory neurons

有人能帮我解决这个错误吗?谢谢。 此SNN(脉冲神经网络)的代码为:

import brian2
from brian2 import *
from brian2 import start_scope

taum = 20 * ms # membrane time constant
taue = 5 * ms # excitatory synaptic time constant
taui = 10 * ms # inhibitory synaptic time constant
Vt = -50 * mV # spike threshold
Vr = -60 * mV # reset value
El = -49 * mV # resting potential
we = (60 * 0.27 / 10) * mV # excitatory synaptic weight
wi = (20 * 4.5 / 10) * mV # inhibitory synaptic weight
eqs = Equations('''
dV/dt = (ge-gi-(V-El))/taum : volt
dge/dt = -ge/taue : volt
dgi/dt = -gi/taui : volt
''')
G = NeuronGroup(4000, model=eqs, threshold=Vt, reset=Vr)
Ge = G.subgroup(3200) # Excitatory neurons
Gi = G.subgroup(800) # Inhibitory neurons
Ce = Connection(Ge, G, 'ge', sparseness=0.02, weight=we)
Ci = Connection(Gi, G, 'gi', sparseness=0.02, weight=wi)
M = SpikeMonitor(G)
MV = StateMonitor(G, 'V', record=0)
Mge = StateMonitor(G, 'ge', record=0)
Mgi = StateMonitor(G, 'gi', record=0)
G.V = Vr + (Vt - Vr) * rand(len(G))
run(500 * ms)

subplot(211)
raster_plot(M, title='The CUBA network', newfigure=False)
subplot(223)
plot(MV.times / ms, MV[0] / mV)
xlabel('Time (ms)')
ylabel('V (mV)')
show()
subplot(224)
plot(Mge.times / ms, Mge[0] / mV)
plot(Mgi.times / ms, Mgi[0] / mV)
xlabel('Time (ms)')
ylabel('ge and gi (mV)')
legend(('ge', 'gi'), 'upper right')
show()

Tags: thresholdplotbrian2msvrweightneuronsvt
1条回答
网友
1楼 · 发布于 2024-06-16 17:29:36

根据以下内容在Brian2中定义子组:

例如,我们有p(神经元群),我们想要它的两个子群。你知道吗

P = NeuronGroup(4000, model=eqs, threshold='v>-20*mV', refractory=3*ms, method='exponential_euler')

Pe = P[:3200]

Pi = P[3200:]

在我的问题中,我用的是布莱恩的指示,而不是布莱恩的指示!所以我收到了错误。 小心使用Brian2和Brian的指令!你知道吗

相关问题 更多 >