BrainPy-style Examples#

Complete, runnable examples built with the native brainpy.state API: composable neurons, synapses, AlignPre/AlignPost projections, and surrogate-gradient training. Every script lives in the examples/brainpy_like/ directory of the repository.

Each card is tagged along two axes:

How to read the tags

  • WorldSimulation reproduces neuroscience dynamics; Training learns weights by gradient descent through the spiking model.

  • Difficultybeginner (single mechanism, short), intermediate (a full network or training loop), advanced (multi-mechanism models or paper-scale reproductions).

These tags describe scope, not stability — every example is production-ready.

If you are new here, start with 5-minute tour and the Tutorial 1 · Your first neuron tutorial track, then come back to adapt one of these.

Balanced & E/I networks#

The canonical excitatory-inhibitory balanced networks — the natural home of the AlignPost projection (see AlignPre / AlignPost — the keystone).

Brunel random network (Builder)

Two populations, random fixed-indegree COBA wiring, built with the imperative Builder API — the flagship Network-API example.

Simulation · beginner

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/brunel.py
COBA balanced network (2005)

Vogels-Abbott conductance-based E/I network with AlignPostProj + Expon + COBA. The reference simulation pattern.

Simulation · beginner

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/103_COBA_2005.py
CUBA balanced network (2005)

The current-based variant of Vogels-Abbott — simpler and faster than COBA.

Simulation · beginner

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/104_CUBA_2005.py
CUBA balanced network (variant)

A second construction of the CUBA network showing an alternative wiring style.

Simulation · intermediate

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/104_CUBA_2005_version2.py
EI balanced network (1996)

Van Vreeswijk & Sompolinsky balanced network exhibiting chaotic asynchronous-irregular firing.

Simulation · intermediate

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/102_EI_net_1996.py
COBA with Hodgkin-Huxley neurons (2007)

The COBA benchmark rebuilt on biophysically detailed Hodgkin-Huxley cells.

Simulation · intermediate

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/106_COBA_HH_2007.py

Oscillations & rhythms#

Network rhythms — gamma generation, synchrony, and fast oscillations.

Interneuron gamma (1996)

Wang & Buzsaki inhibition-based gamma (30-80 Hz) in a hippocampal interneuron network.

Simulation · intermediate

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/107_gamma_oscillation_1996.py
Synfire chains (1999)

Diesmann et al. reliable propagation of synchronous spike volleys through a feedforward chain.

Simulation · intermediate

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/108_synfire_chains_199.py
Fast global oscillation

Brunel & Hakim fast (>100 Hz) global oscillations in sparsely-connected inhibitory networks with low firing rates.

Simulation · intermediate

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/109_fast_global_oscillation.py
Gamma mechanisms — AI state (2021)

Susin & Destexhe asynchronous-irregular background state (no rhythm).

Simulation · advanced

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/110_Susin_Destexhe_2021_gamma_oscillation_AI.py
Gamma mechanisms — CHING (2021)

Susin & Destexhe coherent high-frequency inhibition-based gamma.

Simulation · advanced

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/111_Susin_Destexhe_2021_gamma_oscillation_CHING.py
Gamma mechanisms — ING (2021)

Susin & Destexhe pure-inhibitory (ING) gamma generation.

Simulation · advanced

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/112_Susin_Destexhe_2021_gamma_oscillation_ING.py
Gamma mechanisms — PING (2021)

Susin & Destexhe pyramidal-interneuron (PING) gamma — the E-I loop.

Simulation · advanced

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/113_Susin_Destexhe_2021_gamma_oscillation_PING.py
Gamma mechanisms — combined driver (2021)

The combined Susin & Destexhe model exploring all four gamma regimes in one script.

Simulation · advanced

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/Susin_Destexhe_2021_gamma_oscillation.py

Reproductions & large models#

Paper-scale simulations and signal-propagation studies.

Cortical microcircuit model

A multi-layer cortical column model with layer-specific LIF populations and connectivity.

Simulation · advanced

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/203_cortical_model.py
Inter-areal propagation (Joglekar 2018)

Joglekar et al. graded vs all-or-none signal propagation across a connectome-constrained network of cortical areas.

Simulation · advanced

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/204_joglekar_2018_propagation.py

Training spiking networks#

Gradient-based training through the spiking model with surrogate gradients (see Differentiability).

Surrogate-gradient LIF

Train a small spiking network on a synthetic task with surrogate gradients (the spytorch tutorial 1 reproduction).

Training · beginner

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/200_surrogate_grad_lif.py
Fashion-MNIST SNN

A multi-layer spiking network classifying Fashion-MNIST end to end (spytorch tutorials 2 & 3).

Training · intermediate

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/201_surrogate_grad_lif_fashion_mnist.py
MNIST with a rate readout

MNIST classification with a LeakyRateReadout decoding spikes into class scores.

Training · intermediate

https://github.com/chaobrain/brainpy.state/blob/main/examples/brainpy_like/202_mnist_lif_readout.py

See Also#