snnlab
Examples

Examples

Small runnable examples for authoring, simulation, training and visualisation.

These standalone examples demonstrate the general workflow with small CPU runs. Each page contains complete code, a Python download, expected results and links to its API contracts. No dataset download is required.

Choose an example

ExampleLearn how toProduces
Build a portable circuitAuthor, compile, reload and plan a graphA portable bundle
Simulate a driven E/I circuitGenerate Poisson input and inspect spikesAn activity archive
Replay dense and sparse spikesBind an exact event stream in two representationsChecked raw counts
Train a two-class readoutDeclare a recipe, update weights and inferA training checkpoint
Save and resume trainingContinue training and compare to a full runA checkpoint and equality checks
Plot retained activityTurn retained arrays into a raster and voltage figureA PNG and recording archive

Getting started

  1. Install snnlab, or run uv sync from a repository checkout.
  2. Choose a page and run its script from the repository root. Downloads also run in an environment with snnlab installed.
  3. Inspect the printed results and any files under artifacts/examples/.
  4. Change one declared setting, such as the input rate, timestep or learning rate, and rerun the example.

The examples use explicit graph execution, physical timing and small synthetic fixtures. They teach interfaces; they do not report dataset accuracy, establish scientific acceptance criteria or guarantee cross-device equality. The training example evaluates its own fixture and says so explicitly.

Check every example

uv run python docs/scripts/check_examples.py

This runs the exact downloadable scripts in a temporary directory and checks their assertions. The package CI runs the same command. The rendered pages and downloads are generated from the scripts so copying code from a page cannot drift away from its executable source.

On this page