← all repositories
attractivechaos/kann

Neural nets without the dependency hangover

KANN exists so you can train small-to-medium neural networks in plain C without importing a framework the size of an operating system.

757 stars C ML Frameworks
kann
Not currently ranked — collecting fresh signals.
star history

What it does

KANN is a standalone C library for building and training small-to-medium neural networks—MLPs, CNNs, and RNNs including LSTM and GRU—using graph-based reverse-mode automatic differentiation. It compiles into four source files with no non-standard dependencies, making it embeddable anywhere an ANSI C compiler exists. You construct models by wiring a computational graph, train them via mini-batched gradient descent, and run inference without worrying about runtime bloat.

The interesting bit

The whole library is under 4,000 lines of C, yet it supports weight sharing, multiple inputs and outputs, and topologically weird architectures that lighter frameworks choke on. The author explicitly warns that this is not a TensorFlow killer—CPU-only, small networks—but notes that KANN’s intra-batch threading can actually outrun mainstream frameworks when they are restricted to CPU-only mode.

Key highlights

  • Entire library ships as four files (kautodiff.h, kautodiff.c, kann.h, kann.c) with no installation step.
  • Supports recurrence, shared weights, and non-standard topologies via a low-level computational graph API.
  • Optional BLAS linking (HAVE_CBLAS) speeds up matrix multiplication, though the built-in SSE implementation is already competitive on small networks.
  • Compatible with ANSI C; no GPU required or supported.

Caveats

  • CPU only; the author states it is not intended for training huge networks and that GPU benchmarks are where mainstream frameworks actually win.
  • Missing modern conveniences like batch normalization.
  • The README admits that training RNNs requires verbose, low-level API calls.

Verdict

Worth a look if you need a drop-in neural net for an embedded C/C++ project or want to understand how autodiff works under the hood. Skip it if you need GPU acceleration, batch normalization, or a polished high-level API.

Frequently asked

What is attractivechaos/kann?
KANN exists so you can train small-to-medium neural networks in plain C without importing a framework the size of an operating system.
Is kann open source?
Yes — attractivechaos/kann is an open-source project tracked on heatdrop.
What language is kann written in?
attractivechaos/kann is primarily written in C.
How popular is kann?
attractivechaos/kann has 757 stars on GitHub.
Where can I find kann?
attractivechaos/kann is on GitHub at https://github.com/attractivechaos/kann.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.