# Spiking Neural Networks

**URL:** <https://discourse.julialang.org/t/spiking-neural-networks/63270>\
**Category:** Modelling & Simulations\
**Tags:** biology, neural-network\
**Created:** [June 21, 2021, 3:58am UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270 "2021-06-21T03:58:15Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![wsphillips](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsphillips/32/6777_2.png) [@wsphillips](https://discourse.julialang.org/u/wsphillips)\
**Post date:** [November 2, 2021, 3:43pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/21 "2021-11-02T15:43:47Z")

</div>

It will. And technically you could do it right now, it’s just not convenient yet and the component interfaces need documentation. Initially the focus has been on small models with conductance-based HH dynamics. But the type system in `Conductor.jl` is being intentionally setup to allow substitution of arbitrary (e.g. simplified/artificial) dynamics. Going in the other direction, we’ll be extending to spatial models (e.g. branched cable models of neurons), alternative ion channel model types (e.g. Markov/Jump systems) etc.

---

<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:** [November 2, 2021, 8:32pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/22 "2021-11-02T20:32:55Z")

</div>

> [@ChrisRackauckas](#):
>
> [GitHub - wsphillips/Conductor.jl: Choo-choo](https://github.com/wsphillips/Conductor.jl) has come along since then, and it’s coming along well.

Cool!

On a related note, I recently tried to simulate a network of simple [escape noise neurons](https://neuronaldynamics.epfl.ch/online/Ch9.S1.html) with DiffEq. Each neuron is modelled with some input current I(t) and membrane potential u(t) that evolve according to

\begin{align} \tau\_s \dot I &= -I(t)\\ \tau\_m \dot u &= -(u\_0-u(t)) + RI(t)\\ \end{align}

The neurons spike stochastically with rate \rho(t) = f(u(t) - \vartheta). At every spike of neuron i its membrane potential gets reset to u\_\mathrm{reset} and the synaptic current of each postsynaptic j neuron gets increased by w\_{ji}.

For the following proof-of-principle I used \tau\_s = 2, \tau\_m = 10, u\_0 = R = 1, u\_\mathrm{reset} = 0 and \rho(t) = 0.1\exp(u(t) - 1). This is the code I used

```julia
function update(du, u, p, t)
    du[1:p.N] .= -0.5 * u[1:p.N] # current I
    du[p.N+1:2*p.N] .= .1 * (1 .- u[p.N+1:2*p.N] .+ u[1:p.N]) # potential u
end
rate(i) = (u, p, t) -> .1 * exp(u[i] - 1) # escape rate
spike(i) = function(integrator)
    integrator.u[i+integrator.p.N] = 0 # reset membrane potential
    integrator.u[1:integrator.p.N] .+= integrator.p.W[i] # update postsynaptic currents
end

N = 50 # number of neurons
p = (N = N, W = [.1*randn(N) for _ in 1:N],)
prob = JumpProblem(ODEProblem(update, .1*rand(2N), (0., 1000.), p),
                   [VariableRateJump(rate(i), spike(i)) for i in 1:N]...)
sol = solve(prob)

```

It works, but it doesn’t scale, i.e. already for `N = 100` neurons creating the `JumpProblem` takes a really long time (I aborted after a few minutes). Is there a better way of doing this?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 2, 2021, 9:17pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/23 "2021-11-02T21:17:57Z")

</div>

VariableRateJumps are super duper expensive. I would use any other noise form over them if you need to scale.

---

<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:** [November 3, 2021, 9:28am UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/24 "2021-11-03T09:28:48Z")

</div>

> [@ChrisRackauckas](#):
>
> I would use any other noise form over them if you need to scale.

Well, I think mathematically it as a variable rate jump process. Is there another way to simulate this with `DifferentialEquations` without using `VariableRateJump`? (In practice we usually use some hand-crafted version of Euler-Maruyama, but I wanted to give `DifferentialEquations` a try here).

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 7, 2021, 2:16pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/25 "2021-11-07T14:16:19Z")

</div>

Crude SDE approximations will be a lot faster. We can make VariableRateJump a lot faster, but it’s always going to be a computationally hard mechanism. Modeling those as regular jumps could be better too with a tau-leaping approximation.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [December 20, 2021, 5:12pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/26 "2021-12-20T17:12:40Z")

</div>

Hi,

Do you have a working version of this network by any chance? I am planning to write it but if one is already available… 😉

---

<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:** [December 20, 2021, 5:36pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/27 "2021-12-20T17:36:30Z")

</div>

I don’t have implementations of networks of the Bellec et al. paper. But I used this approach with toy networks to compare to other fitting methods in the presence of hidden neurons (might end up in a follow-up to [Fitting summary statistics of neural data with a differentiable spiking network simulator](https://proceedings.neurips.cc/paper/2021/hash/9a32ff36c65e8ba30915a21b7bd76506-Abstract.html)). What exactly are you interested in?

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [December 20, 2021, 5:48pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/28 "2021-12-20T17:48:02Z")

</div>

The code (python) with that paper is fairly slow. I am using it for some research and I wanted to try a Julia version to see if there is any speed gain.

---

<div class="post-metadata">

**Author:** ![alequa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alequa/32/12338_2.png) [@alequa](https://discourse.julialang.org/u/alequa)\
**Post date:** [April 7, 2022, 3:03pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/29 "2022-04-07T15:03:32Z")

</div>

Hello,

I append to this discussion because it seems the right one.

Would anybody of you be interested in preparing a _Birds of a feather / Interest group_ at the next JuliaCon about SNN?

I am about to propose it, but I would be happy of preparing it in collaboration with someone. In case contact me and I will forward you the short text am about to submit for the conference.

Best,

> **[JuliaCon 2022 (Times are UTC)](https://pretalx.com/juliacon-2022/cfp)**
>
> Schedule, talks and talk submissions for JuliaCon 2022 (Times are UTC)

---

<div class="post-metadata">

**Author:** ![bjarthur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarthur/32/9638_2.png) [@bjarthur](https://discourse.julialang.org/u/bjarthur)\
**Post date:** [April 10, 2022, 1:39pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/30 "2022-04-10T13:39:19Z")

</div>

i would attend a BoF on computational neuroscience.

i’ve submitted a juliacon talk proposal titled [Training Spiking Neural Networks in pure Julia](https://pretalx.com/juliacon-2022/talk/review/LU3V7R7TJKL3DDLVXFV3MWTR8Q9BYXEE). we plan to make the corresponding code public in the next month or so after we submit a manuscript.

---

<div class="post-metadata">

**Author:** ![alequa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alequa/32/12338_2.png) [@alequa](https://discourse.julialang.org/u/alequa)\
**Post date:** [April 10, 2022, 3:10pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/31 "2022-04-10T15:10:10Z")

</div>

Your project sounds very interesting, but indeed it is a talk and quite specific to a type of network and supervised learning scheme.  
Instead, I was thinking about a more broad discussion that reflects the opening of this thread, the opening talk structure would look like this:

- What an SNN simulator in Julia is supposed to achieve (experimenting with new neuron models and protocols versus large scale simulations), can Conductor.jl cover the whole spectrum of simulation types? Or a different, compatible package would rather do the job?

- What would such a simulator look like (I personally really like the ideas behind AStupidBear/SNN [2])? How do you instantiate new models and define the equations such that it stays flexible and fast?

- And how do you achieve it? Is EqDiff.jl support the best for all models, or when we move towards more abstract types of neurons we better have time-step-based models? and can we use shared memory parallelism or Cuda in that case?

I think that there are several people who are more competent than me for opening this discussion (like many of the people who answered this thread), but I would really like to build it up and see if we can get to a community consensus on what is worth to work on.

So I will wrap up the discussion that has been going on here and hope that the same people will join during the BoF. I will keep this thread posted on the talk I intend to prepare to open the discussion so that we can keep in it all the relevant discussion points.

Best,  
Alessio

[1] W. Nicola and C. Clopath, ‘Supervised learning in spiking neural networks with FORCE training’, Nature Communications, vol. 8, no. 1, p. 2208, Dec. 2017, doi: 10/gcr4j2.  
[2] [GitHub - AStupidBear/SpikingNeuralNetworks.jl: Julia Spiking Neural Network Simulator](https://github.com/AStupidBear/SpikingNeuralNetworks.jl)

---

<div class="post-metadata">

**Author:** ![alequa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alequa/32/12338_2.png) [@alequa](https://discourse.julialang.org/u/alequa)\
**Post date:** [April 11, 2022, 11:08pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/32 "2022-04-11T23:08:01Z")

</div>

I proposed this BoF for JuliaConf22:

> **[Simulating neural physiology & networks in Julia JuliaCon 2022 (Times are...](https://pretalx.com/juliacon-2022/talk/review/GEXXMFENGSPK3RRFTHRLTZ9U87GVU9XW)**
>
> Julia’s software ecosystem certainly lessens the technical burden for computational neuroscientists—it boasts federated development of high-quality packages for solving differential equations, machine learning, automatic differentiation, and symbolic...

As said in previous posts, I would be happy to collaborate with others in building up the introductory talk.  
I will keep you updated with the content of the introductory talk in the coming months.

---

<div class="post-metadata">

**Author:** ![alequa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alequa/32/12338_2.png) [@alequa](https://discourse.julialang.org/u/alequa)\
**Post date:** [April 7, 2025, 3:12pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/33 "2025-04-07T15:12:29Z")

</div>

Hello everyone,

I am happy to re-bump on this topic and inform you that the AStupidBear/SpikingNeuralNetwork.jl simulator had walked many many steps ahead in the last months and it is now a sweet and efficient library for biophysical simulations, that you can find here:

> **[Julia Spiking Neural Networks](https://github.com/JuliaSNN)**
>
> Collection of libraries to simulate Spiking Neural Networks in Julia. - Julia Spiking Neural Networks

The library is still work in progress, but the main functionalities are now very stable and one can run fairly complex network models.

For the moment there are only two active developers, but if you would like to start using it/ improving it, contact me and we surely will arrange something.

You can check out some relevant examples here:

> **[SNNExamples/experiments at main · JuliaSNN/SNNExamples](https://github.com/JuliaSNN/SNNExamples/tree/main/experiments)**
>
> Collection of examples from the JuliaSNN organization - JuliaSNN/SNNExamples

---

<div class="post-metadata">

**Author:** ![Dhruva2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhruva2/32/18475_2.png) [@Dhruva2](https://discourse.julialang.org/u/Dhruva2)\
**Post date:** [July 9, 2026, 4:32pm UTC](https://discourse.julialang.org/t/spiking-neural-networks/63270/34 "2026-07-09T16:32:19Z")

</div>

SNNExamples looks cool! I built NeuronBuilder a while ago (with lots of help from Pavel Piekarz and Andrea Hincapie) and gave up for various reasons. With the new ModelingToolkit it’s much easier and less hacky to compose components like ion channels etc so now have [[ANN] MTKNeuralToolkit.jl- acausal modelling of biophysical neurons and neural circuits](https://discourse.julialang.org/t/ann-mtkneuraltoolkit-jl-acausal-modelling-of-biophysical-neurons-and-neural-circuits/138039)

which is a WIP. Improvements and suggestions really welcomed. But the code fells much cleaner and more minimal/extensible. Got the core stuff working like networks and calcium tracking/calcium channels, and compartmental geometries/morphologies (though this could be extended)

i’m hoping the fundamentals that exist right now don’t need to be changed and will easily support extending to more functionality

[Previous page](https://discourse.julialang.org/t/spiking-neural-networks/63270.md?page=1)
