NumpyBrain:神经元动力学模拟的实时编译方法。

npbrain的Python项目详细描述


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

{1:{emstrong}项目属于^/mprain。更多功能即将推出。欢迎投稿。

为什么使用NumpyBrain

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

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

Speed comparison with brian2

更多关于NumpyBrain的详细信息请参见我们的document。在

安装

使用pip安装NumpyBrain

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

从源代码安装:

^{pr2}$

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

  • Python>;=3.5
  • 13.1加仑
  • 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不兼容类型:MainActivity无法转换为LifecycleOwner   java安卓是一种更有效的读取大文本文件的方法   java导出LWJGL本地人与项目?(IntelliJ IDEA)   JDK更新后,JavaJShell不再在下一行打印输出   父类对象上的继承Java比较子属性   Java:有没有一个容器可以有效地结合HashMap和ArrayList?   安卓 Java对象指针   java在annotationdriven Spring MVC应用程序中实现大气   java 安卓源代码构建应用找不到安卓supportv4。罐子   文件系统上的抽象层和Java中的jar/zip   java在水平滚动视图中添加多个图像?   java如何从firebase实时数据库中获取字符串数组   WIndows 10工作站上的java未满足链接错误   java命令在终端中工作,但在使用过程中出现“无结束引号”错误。执行官