# Spiking Neural Network

**URL:** https://discourse.julialang.org/t/spiking-neural-network/24908
**Category:** Modelling & Simulations
**Created:** [June 4, 2019, 5:48am UTC](https://discourse.julialang.org/t/spiking-neural-network/24908 "2019-06-04T05:48:34Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)
#### Post date: [June 4, 2019, 5:48am UTC](https://discourse.julialang.org/t/spiking-neural-network/24908/1 "2019-06-04T05:48:34Z")

</div>

Hi,  
I am trying to implement the spiking neural network model in this paper [https://www.frontiersin.org/articles/10.3389/fninf.2018.00079/full](https://www.frontiersin.org/articles/10.3389/fninf.2018.00079/full) and I wanted to use DifferentialEquations.jl Basically, the model consists of a network of so-called integrate-and-fire units, i.e. units where the membrane potential is governed by this simple equation

![eq1](https://global.discourse-cdn.com/julialang/original/3X/2/9/2917a55dc841c6fdcb636bb9468998bfa7cd0c7c.png)

where **w** are the connection weights from all units to unit _i_ and **a** (t) is the spiking activity of the other units.  
A unit emits a spike when the membrane potential _V_ exceeds a specified threshold, after which it is reset to its resting value.  
My initial thought was to make use of callbacks to manage the spiking activity, as it involves directly manipulating the value of what is being integrated. However, it wasn’t clear to me how to manage multiple callbacks (it seems I would need one callback per unit, so potentially hundreds of them). I am aware of [https://github.com/JuliaDiffEq/DiffEqBase.jl/pull/221](https://github.com/JuliaDiffEq/DiffEqBase.jl/pull/221), which seems to address my need. I guess my question is, should I wait for this PR to be merged, or is there a better way of handling a spiking neural network model? Thanks!

---

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [June 4, 2019, 8:03am UTC](https://discourse.julialang.org/t/spiking-neural-network/24908/2 "2019-06-04T08:03:36Z")

</div>

> [@grero](#):
>
> should I wait for this PR to be merged

Sorry, not much of help here, but I think there is a way for you to use a specific PR of a package with `Pkg`, so at least you won’t need to wait until that PR is merged.

---

<div class="post-metadata">

### Author: ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)
#### Post date: [June 4, 2019, 8:49am UTC](https://discourse.julialang.org/t/spiking-neural-network/24908/3 "2019-06-04T08:49:55Z")

</div>

It depends how you define a callback for spikes. If it is just thresholding,then make a DiscreteCallback with always codition `true` and use `affect!` to find if there are states above the threshold. Depending how fast the spikes occur, you may miss if the time steps high though.

---

<div class="post-metadata">

### Author: ![jbrea](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbrea/32/3879_2.png) [@jbrea](https://discourse.julialang.org/u/jbrea)
#### Post date: [June 4, 2019, 2:33pm UTC](https://discourse.julialang.org/t/spiking-neural-network/24908/4 "2019-06-04T14:33:24Z")

</div>

In case you don’t want to use DifferentialEquations.jl, there is [this somewhat outdated talk](https://www.youtube.com/watch?v=cLLQcshWEbE) on simulating spiking neural networks with julia (I don’t think that there is a public repository available) and we have a preliminary version of a spiking neural network integrator [here](https://github.com/EPFL-LCN/pub-illing2019-nnetworks/tree/master/core/src/lifintegrator/core) (docs and further improvements to come).

---

<div class="post-metadata">

### Author: ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)
#### Post date: [June 4, 2019, 4:11pm UTC](https://discourse.julialang.org/t/spiking-neural-network/24908/5 "2019-06-04T16:11:34Z")

</div>

Thanks! Those are all really useful resources. I’ll definitely take a look and let you guys know how it goes.

---

<div class="post-metadata">

### Author: ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)
#### Post date: [June 4, 2019, 11:36pm UTC](https://discourse.julialang.org/t/spiking-neural-network/24908/6 "2019-06-04T23:36:42Z")

</div>

@jbrea your paper sounds really interesting, I will definitely give it a read : )
