Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
A lightweight C library for artificial neural networks
| Date | Stars |
|---|---|
| 2026-08-05 | 760 |
| 2026-08-06 | 760 |
| 2026-08-07 | 760 |
| 2026-08-14 | 760 |
| 2026-08-15 | 760 |
| 2026-08-18 | 760 |
| 2026-08-21 | 759 |
| 2026-09-15 | 760 |
| 2026-09-25 | 761 |
| 2026-09-27 | 760 |
| 2026-10-01 | 761 |
| 2026-10-11 | 762 |
| 2026-10-20 | 763 |
| 2026-11-04 | 763 |
Today
— stars today
This week
— stars this week
This month
+2 stars this month
Momentum
0.0
growth rate 0.00%/day
## Getting Started
```sh
# acquire source code and compile
git clone https://github.com/attractivechaos/kann
cd kann; make # or "make CBLAS=/path/to/openblas" for faster matrix multiplication
# learn unsigned addition (30000 samples; numbers within 10000)
seq 30000 | awk -v m=10000 '{a=int(m*rand());b=int(m*rand());print a,b,a+b}' \
| ./examples/rnn-bit -m7 -o add.kan -
# apply the model (output 1138429, the sum of the two numbers)
echo 400958 737471 | ./examples/rnn-bit -Ai add.kan -
```
## Introduction
KANN is a standalone and lightweight library in C for constructing and training
small to medium artificial neural networks such as [multi-layer
perceptrons][mlp], [convolutional neural networks][cnn] and [recurrent neural
networks][rnn] (including [LSTM][lstm] and [GRU][gru]). It implements
graph-based reverse-mode [automatic differentiation][ad] and allows to build
topologically complex neural networks with recurrence, shared weights and
multiple inputs/outputs/costs. In comparison to mainstream deep learning
frameworks such as [TensorFlow][tf], KANN is not as scalable, but it is close
in flexibility, has a much smaller code base and only depends on the standard C
library. In comparison to other lightweight frameworks such as [tiny-dnn][td],
KANN is still smaller, times faster and much more versatile, supporting RNN,
VAE and non-standard neural networks that may fail these lightweight
frameworks.
KANN could be potentially useful when you want to experiment small to medium
neural networks in C/C++, to deploy no-so-large models without worrying about
[dependency hell][dh], or to learn the internals of deep learning libraries.
### Features
* Flexible. Model construction by building a computational graph with
operators. Support RNNs, weight sharing and multiple inputs/outputs.
* Efficient. Reasonably optimized matrix product and convolution. Support
mini-batching and effective multi-threading. Sometimes faster than mainstream
frameworks in their CPU-only mode.
* Small and portable. As of now, KANN has less than 4000 lines of code in four
source code files, with no non-standard dependencies by default. Compatible with
ANSI C compilers.
### Limitations
* CPU only. As such, KANN is **not** intended for training huge neural
networks.
* Lack of some common operators and architectures such as batch normalization.
* Verbose APIs for training RNNs.
## Installation
The KANN library is composed of four files: `kautodiff.{h,c}` and `kann.{h,c}`.
You are encouraged to include these files in your source code tree. No
installation is needed. To compile examples:
```sh
make
```
This generates a few executables in the [examples](examples) directory.
## Documentations
Comments in the header files briefly explain the APIs. More documentations can
be found in the [doc](doc) directory. Examples using the library are in the
[examples](examples) directory.
### A tour of basic KANN APIs
Working with neural networks usually involves three steps: model construction,
training and prediction. We can use layer APIs to build a simple model:
```c
kann_t *ann;
kad_node_t *t;
t = kann_layer_input(784); // for MNIST
t = kad_relu(kann_layer_dense(t, 64)); // a 64-neuron hidden layer with ReLU activation
t = kann_layer_cost(t, 10, KANN_C_CEM); // softmax output + multi-class cross-entropy cost
ann = kann_new(t, 0); // compile the network and collate variables
```
For this simple feedforward model with one input and one output, we can train
it with:
```c
int n; // number of training samples
float **x; // model input, of size n * 784
float **y; // model output, of size n * 10
// fill in x and y here and then call:
kann_train_fnn1(ann, 0.001f, 64, 25, 10, 0.1f, n, x, y);
```
We can save the model to a file with `kann_save()` or use it to classify a
MNIST image:
```c
float *x; // of size 784
const float *y; // this will point to an array of size 10
// fill in x here and then call:
y = kann_apply1(ann, x);
``Excerpt of 10,651 characters
Read on GitHub512
13
2
Tim Gates · IRESS · Australia
1
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:af0d5478bcf945cb, topic:deep-learning, topic:neural-network, readme:automatic differentiation