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
| Example | Learn how to | Produces |
|---|---|---|
| Build a portable circuit | Author, compile, reload and plan a graph | A portable bundle |
| Simulate a driven E/I circuit | Generate Poisson input and inspect spikes | An activity archive |
| Replay dense and sparse spikes | Bind an exact event stream in two representations | Checked raw counts |
| Train a two-class readout | Declare a recipe, update weights and infer | A training checkpoint |
| Save and resume training | Continue training and compare to a full run | A checkpoint and equality checks |
| Plot retained activity | Turn retained arrays into a raster and voltage figure | A PNG and recording archive |
Getting started
- Install snnlab, or run
uv syncfrom a repository checkout. - Choose a page and run its script from the repository root. Downloads also run in an environment with snnlab installed.
- Inspect the printed results and any files under
artifacts/examples/. - 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.pyThis 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.