kann logo

kann

Free

A lightweight C library for artificial neural networks.

FreeFree tier
Type
Open Source

About kann

KANN is a standalone and lightweight C library for constructing and training small to medium artificial neural networks. It supports multi-layer perceptrons (MLP), convolutional neural networks (CNN), and recurrent neural networks (RNN) including LSTM and GRU. The library implements graph-based reverse-mode automatic differentiation, enabling topologically complex networks with recurrence, shared weights, and multiple inputs/outputs/costs. With less than 4000 lines of code and no non-standard dependencies, it is portable and compatible with ANSI C compilers. It features optimized matrix products and convolution, mini-batching support, and effective multi-threading for CPU execution. KANN is intended for experimenting with small to medium neural networks in C/C++, deploying models without dependency issues, or learning deep learning internals.

Key Features

Graph-based reverse-mode automatic differentiation
Supports MLP, CNN, RNN (LSTM, GRU)
Weight sharing and multiple inputs/outputs/costs
Optimized matrix product and convolution operations
Mini-batching and multi-threading support
Less than 4000 lines of code, no non-standard dependencies
ANSI C compatible, portable

Pros & Cons

Pros
  • Very small and lightweight codebase
  • No external dependencies (only standard C library)
  • Flexible computational graph construction
  • Efficient CPU-only execution with mini-batching and multi-threading
  • Supports advanced architectures like RNN, LSTM, GRU
  • Portable across ANSI C compilers
Cons
  • CPU only, not intended for training huge neural networks
  • Lacks batch normalization and some common operators
  • Verbose APIs for training RNNs

Best For

Experimenting with small to medium neural networks in C/C++Deploying no-so-large models without dependency hellLearning the internals of deep learning librariesImplementing custom neural network architectures with recurrence or shared weights

FAQ

What is KANN?
KANN is a standalone, lightweight C library for constructing and training small to medium artificial neural networks, including MLPs, CNNs, and RNNs (LSTM/GRU). It uses graph-based automatic differentiation.
What are the main limitations of KANN?
KANN is CPU only and not intended for huge networks. It lacks batch normalization and some common operators, and its RNN training APIs are verbose.
How do I install KANN?
No installation is needed. Just include the four source files (kautodiff.h, kautodiff.c, kann.h, kann.c) in your project and compile with a standard C compiler.