A pure-Julia implementation of a biologically plausible spiking neural network combining five plasticity mechanisms with excitatory-inhibitory balance.
First pure-Julia SORN combining:
- Pair STDP — Hebbian learning on E→E connections
- Inhibitory STDP — Anti-Hebbian learning on I→E connections
- Synaptic Scaling — Homeostatic weight normalization
- Intrinsic Plasticity — Adaptive spike thresholds (LIF)
- Structural Plasticity — Dynamic synapse formation/elimination
with biologically realistic 80:20 E/I balance.
- Excitatory neurons: Leaky Integrate-and-Fire with adaptive threshold
- Inhibitory neurons: Izhikevich fast-spiking model
- Connectivity: Sparse random with 80:20 E/I ratio
- Weight matrices: E→E (plastic), I→E (plastic), E→I (fixed), Input→E (fixed)
- Sparse weight matrices (
SparseMatrixCSC) — only stores 15% non-zero connections - Struct-of-arrays layout for SIMD vectorization
- Zero-allocation simulation loop
- All inner loops
@simd-vectorized (neuron updates, current computation, weight scaling, recording) - Analytical LIF solution (exact ODE integration, not Euler approximation)
- Exponential decay for threshold adaptation and synaptic scaling
- Structural plasticity rebuilds from IJV triplets (avoids O(nnz) per-insertion cost)
| Neurons | 500ms sim | 1000ms sim |
|---|---|---|
| 100 | ~50ms | ~100ms |
| 200 | ~60ms | ~130ms |
| 400 | ~480ms | ~960ms |
| 800 | ~2s | ~4s |
| 1600 | ~10s | ~20s |
julia --project=. examples/demo.jlSORN/
├── src/
│ ├── SNN.jl # Main module
│ ├── utils.jl # Poisson sampling, trace decay
│ ├── neurons.jl # LIF + Izhikevich pools
│ ├── plasticity.jl # 5 plasticity mechanisms
│ ├── network.jl # SORN architecture
│ ├── simulation.jl # Simulation loop
│ └── encoding.jl # Input encoding
├── examples/
│ ├── demo.jl # Full demonstration
│ └── benchmark.jl # Performance benchmarks
├── Project.toml
└── README.md
using .SNN
using .SNN.Network: create_sorn
using .SNN.Simulation: simulate!
using .SNN.Encoding: poisson_encode
net = create_sorn(n_exc=80, n_inh=20, n_input=100, seed=42)
input = poisson_encode(100, 1000; rate=0.1)
result = simulate!(net, input; verbose=true)- Computational neuroscience research (cortical microcircuit modeling)
- Neuromorphic computing prototypes
- Studying emergent memory/sequence learning in recurrent networks
- Educational tool for spiking neural network dynamics
- Baseline for comparing plasticity rule combinations
- Lazar et al. (2009) "SORN: a self-organizing recurrent neural network"
- Turrigiano & Nelson (2000) "Homeostatic plasticity in developing networks"