A friendly tour · v0.5

Spiking neural
networks are
convex optimizers.

A simple population of leaky integrate-and-fire neurons, with the right connectivity, solves a quadratic program. Each spike is a constraint becoming active. Each silence is a gradient step. The page below walks through the idea, the math, and a runnable Python implementation.

Install
pip install snn-opt
Backends
Python · C++
License
Apache-2.0
c₁ᵀx ≤ d₁ c₂ᵀx ≤ d₂ c₃ᵀx ≤ d₃ x*ᵤ x₀ x* drift (∇f) spike (proj.) x*ᵤ unconstrained

A 2-D quadratic with three half-space constraints. The trajectory drifts toward x*ᵤ, spikes at each active wall, and settles at the constrained optimum.

Three beats

The idea, distilled.

The whole framework collapses into three repeating moves. Everything else, the convergence proofs, the hardware story, the spike raster, falls out of these.

01

Drift.

Between spikes, each neuron's membrane voltage moves by the gradient of an objective. Plain gradient descent, dressed up as biology.

02

Spike.

When the voltage would push the trajectory past a constraint, a spike fires. The spike re-projects the state onto the feasible boundary: a discrete correction.

03

Settle.

The spike train and the drift balance at the constrained optimum. Active spikes encode the active constraint set. The math is exactly that of a primal-dual QP solver.

A picture

What it
looks like.

An 8-D quadratic whose optimum lies outside a 16-facet polytope. Each dot is one projection event. Watch the network search: one facet fires a short burst and falls silent, three more are recruited in turn and then fire on every step. Those three are exactly the constraints active at the true optimum.

Projection-spike raster on a 4-D box-constrained QP
Top: spike raster, one row per constraint, dot size ∝ projection magnitude; blue rows are active at the optimum, orange are released again. Bottom: objective gap against the exact optimum, same axis. Generated by benchmarks/02_spike_raster.py.

Accuracy

Where it
stops.

The dynamics converge to a fixed point of the discretised flow, which is not quite the minimiser of the QP. The offset shrinks with the gradient step, but a smaller step needs more iterations to arrive, so every iteration budget has its own best setting.

Objective gap against the exact optimum as the step size is swept, at three iteration budgets
Gap against an exact optimum (an active-set KKT solve, not a long run of the solver itself). The shipped default sits right of every knee: on this problem it leaves 6.7e-4, while a smaller step reaches 1.2e-5 given enough iterations. Generated by benchmarks/04_accuracy_tuning.py.

Three fields on the result exist to make this visible, and they are worth checking on any real problem. joint_feasible reports feasibility of the constraint rows and the bounds together. stationarity_residual is a KKT certificate: where converged tells you the network reached a fixed point, this tells you how far that fixed point sits from an actual optimum. projection_budget_exhausted flags a solve that ran out of inner projection steps, which now aborts rather than being reported as success. The repository README has the full treatment.

Map

What you'll
find here.

Four entry points. Pick whichever matches your appetite: the intuition essay, the hands-on tutorials, the published papers, or the source code itself.

Install

Two lines
and you're in.

Prebuilt wheels for Linux (x86_64, aarch64), macOS (Apple Silicon), and Windows across CPython 3.9–3.13. The compiled C++ backend ships inside the wheel; no toolchain needed on your side.

pip install snn-opt

Then head to the Quickstart for a five-minute walkthrough. The PyPI distribution name is snn-opt (hyphenated, per PEP 503); the Python import name is snn_opt. Pick the C++ kernel with backend='c' for a roughly 10× speedup on the inner projection loop. The same kernel source is HLS-compatible and is the basis for the planned FPGA deployment.

For whom

Who this is for.

Students starting a thesis on neuromorphic methods. Researchers from optimization or control who heard "spiking networks" and weren't sure what to make of it. Anyone who finds beauty in connections between fields that look unrelated until they don't.

If you want the formal version: head to the snn_opt repository for the full theory document, an academic-style README, and a benchmark suite. The pages here are the friendly version of the same material.

Acknowledgments

Acknowledgments.

Developed at the School of Artificial Intelligence, Taizhou University.

This codebase implements the SNN-QP research program led by Prof. Shuai Li (IEEE Fellow; Faculty of Information Technology and Electrical Engineering, University of Oulu, Finland), whose work on neurodynamic optimization originated this line of inquiry. The mathematical framework follows Mancoo, Boerlin and Machens (NeurIPS 2020) and the broader projection-neural-network lineage (Hopfield–Tank, Kennedy–Chua, Xia–Wang, Liu–Wang).