glouw/tinn logo

glouw/tinn

Free

A tiny neural network library

FreeFree tier
Type
Open Source

About glouw/tinn

Tinn (Tiny Neural Network) is a minimal, dependency-free neural network library implemented in C99, consisting of less than 200 lines of code. It features a sigmoidal activation function and a single hidden layer, making it extremely lightweight and suitable for embedded systems and resource-constrained environments. The library is portable across platforms that support a C99 or C++98 compiler and relies solely on the C standard library. Tinn includes a demonstration for handwritten digit recognition using the SEMEION dataset, achieving over 99% accuracy on the correct digit. It is designed for simplicity and ease of integration, allowing users to train models on a desktop and deploy them on microcontrollers.

Key Features

Dependency-free implementation in C99, less than 200 lines
Sigmoidal activation function with one hidden layer
Portable across any platform with a C99 or C++98 compiler
Relies only on the C standard library, no external dependencies
Suitable for embedded systems and microcontrollers
Single-threaded to aid embedded development
MIT license for open use and modification

Pros & Cons

Pros
  • Extremely lightweight (under 200 lines) with no dependencies
  • Portable across many platforms and compilers
  • Simple and easy to integrate into C projects
  • Achieves >99% accuracy on handwritten digit demonstration
  • Designed with embedded systems in mind
  • Open source under MIT license
Cons
  • Only supports a single hidden layer (limited network architecture)
  • Single-threaded implementation (multi-threading left to user)
  • No built-in random seed; user must seed the RNG
  • Uses sigmoidal activation only (no support for ReLU, tanh, etc.)
  • Not as feature-rich as other C neural network libraries like Kann or Genann
  • No batch training, advanced optimization, or regularization

Best For

Learning and recognizing handwritten digitsEmbedded systems requiring lightweight neural network inferenceReal-time event prediction using analog-to-digital converters on microcontrollersEducational projects for understanding basic neural network internalsClassification tasks in resource-constrained C environments

FAQ

What is Tinn?
Tinn (Tiny Neural Network) is a minimal, dependency-free neural network library written in C99, containing less than 200 lines of code.
What license is Tinn released under?
Tinn is released under the MIT license, allowing free use, modification, and distribution.
Is Tinn suitable for embedded systems?
Yes, Tinn is specifically designed for embedded systems. It uses only the C standard library and is single-threaded, making it ideal for microcontrollers.
What activation function does Tinn use?
Tinn uses the sigmoidal activation function.
How many hidden layers does Tinn support?
Tinn supports exactly one hidden layer.
Can Tinn be used for handwritten digit recognition?
Yes, Tinn includes a demonstration using the SEMEION dataset that achieves over 99% accuracy on handwritten digit recognition.