我尝试使用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:没有属性带有名称子组
我的主要问题是制作G
(NeuronGroup
)的子组。第一个亚组是兴奋性神经元,第二个是抑制性神经元。
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()
答案 0 :(得分:0)
根据以下内容在Brian2中定义子组:
例如,我们有p(神经元群),我们希望有两个子群。
P = NeuronGroup(4000,模型= eqs,阈值='v> -20 * mV',难治性= 3 * ms, method ='exponential_euler')
Pe = P [:3200]
Pi = P [3200:]
在我的问题中,我使用了Brian而不是Brian2的指令!所以我收到了错误。 使用Brian2和Brian的指令时要小心!