BrianPy:神经元动力学模拟的JustInTime编译方法。

Brian的Python项目详细描述


logoDocumentation Statushttps://anaconda.org/oujago/npbrain/badges/version.svghttps://badge.fury.io/py/npbrain.svg

NoteBrainPy是一个正在开发的项目。更多功能即将推出。欢迎投稿。

为什么要用脑力

BrainPy是SNN(spiking neural network)模拟的微内核框架 完全基于nativepython。它只依赖于NumPy。 但是,如果您想获得更快的性能,您还可以 安装Numba。使用Numba,C或FORTRAN的速度可以 在模拟中得到。在

BrainPy希望提供一个高度灵活和高效的SNN模拟 面向Python用户的框架。它赋予用户完全的数据/逻辑流控制。 这个框架的核心是一个微内核,它很容易理解(参见 How NumpyBrain works)。 基于内核、扩展新模型或定制 数据/逻辑流对于用户来说非常简单。大量的例子(如LIF神经元, 也提供HH神经元或AMPA突触、GABA突触和GapJunction)。 除了考虑flexibility,以加速运行 ^{str1}$speed的NumPy代码,Numba被使用。大多数时候, 在Numba后端运行的模型非常快 (见examples/benchmark)。在

Speed comparison with brian2

有关BrainPy的更多详细信息,请参阅我们的document。在

安装

使用pip安装BrainPy

$> pip install git+https://github.com/PKU-NIP-Lab/BrainPy

从源代码安装:

^{pr2}$

需要安装以下软件包才能使用BrainPy

  • Python>;=3.5
  • 数量=1.13
  • Sympy>;=1.2
  • Matplotlib>;=2.0
  • 自动EP8

建议安装的程序包:

  • 数字=0.40.0
  • JAX>;=0.1.0

定义一个霍奇金-赫胥黎神经元模型

importnpbrain.numpyasnpimportnpbrainasnbdefHH(noise=0.,E_Na=50.,g_Na=120.,E_K=-77.,g_K=36.,E_Leak=-54.387,g_Leak=0.03,C=1.0,Vth=20.):ST=nb.types.NeuState({'V':-65.,'m':0.,'h':0.,'n':0.,'sp':0.,'inp':0.},help='Hodgkin–Huxley neuron state.\n''"V" denotes membrane potential.\n''"n" denotes potassium channel activation probability.\n''"m" denotes sodium channel activation probability.\n''"h" denotes sodium channel inactivation probability.\n''"sp" denotes spiking state.\n''"inp" denotes synaptic input.\n')@nb.integratedefint_m(m,t,V):alpha=0.1*(V+40)/(1-np.exp(-(V+40)/10))beta=4.0*np.exp(-(V+65)/18)returnalpha*(1-m)-beta*m@nb.integratedefint_h(h,t,V):alpha=0.07*np.exp(-(V+65)/20.)beta=1/(1+np.exp(-(V+35)/10))returnalpha*(1-h)-beta*h@nb.integratedefint_n(n,t,V):alpha=0.01*(V+55)/(1-np.exp(-(V+55)/10))beta=0.125*np.exp(-(V+65)/80)returnalpha*(1-n)-beta*n@nb.integrate(noise=noise/C)defint_V(V,t,m,h,n,Isyn):INa=g_Na*m**3*h*(V-E_Na)IK=g_K*n**4*(V-E_K)IL=g_Leak*(V-E_Leak)dvdt=(-INa-IK-IL+Isyn)/Creturndvdtdefupdate(ST,_t_):m=np.clip(int_m(ST['m'],_t_,ST['V']),0.,1.)h=np.clip(int_h(ST['h'],_t_,ST['V']),0.,1.)n=np.clip(int_n(ST['n'],_t_,ST['V']),0.,1.)V=int_V(ST['V'],_t_,m,h,n,ST['inp'])sp=np.logical_and(ST['V']<Vth,V>=Vth)ST['sp']=spST['V']=VST['m']=mST['h']=hST['n']=nST['inp']=0.returnnb.NeuType(requires={"ST":ST},steps=update,vector_based=True)

定义AMPA突触模型

defAMPA(g_max=0.10,E=0.,tau_decay=2.0):requires=dict(ST=nb.types.SynState(['s'],help='AMPA synapse state.'),pre=nb.types.NeuState(['sp'],help='Pre-synaptic state must have "sp" item.'),post=nb.types.NeuState(['V','inp'],help='Post-synaptic neuron must have "V" and "inp" items.'))@nb.integrate(method='euler')defints(s,t):return-s/tau_decaydefupdate(ST,_t_,pre):s=ints(ST['s'],_t_)s+=pre['sp']ST['s']=s@nb.delayeddefoutput(ST,post):post_val=-g_max*ST['s']*(post['V']-E)post['inp']+=post_valreturnnb.SynType(requires=requires,steps=(update,output),vector_based=False)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java矢量图像被拉伸   java如何检查为8085模拟器设置的标志   java更改动态数据列表显示的宽度   重载Java:允许使用一个varargs参数的函数和具有相同名称和一个相同类型参数的函数?   java Google应用程序引擎搜索API赋予某些字段比其他字段更高的优先级   java如何确定Textview在RelativeLayout中的位置   参数按日期排序。比较器。JAVA   继承在Java中,当类A继承类B时,堆中会发生什么   java javafx使用来自MainController或适当控制器类中其他控制器的对象   java ElasticSearch如何从3000万个文档中快速查询一个结果