codeplea/genann

simple neural network library in C99

What it solves

Genann provides a minimal and lightweight way to implement feedforward artificial neural networks (ANN) in C. It removes the complexity of heavy machine learning frameworks, offering a simple, fast, and reliable library for developers who need basic neural network capabilities without external dependencies.

How it works

The library is contained in a single source file and header. It allows users to initialize a network with a specific number of inputs, hidden layers, and outputs. It supports training via standard backpropagation or alternative methods like genetic algorithms and hill climbing, as it stores all network weights in a single contiguous block of memory for easy optimization. It also includes several built-in activation functions such as sigmoid, ReLU, and tanh.

Who it’s for

C developers who want a hackable, dependency-free neural network library for simple tasks, such as XOR functions or basic dataset classification (e.g., the IRIS dataset).

Highlights

  • Zero Dependencies: Written in C99 and requires no external libraries.
  • Contained: The entire project consists of only two files (genann.c and genann.h).
  • Flexible Training: Supports backpropagation as well as direct-search numeric optimization.
  • Thread-Safe: Designed to be fast and safe for use in multi-threaded environments.
  • Persistence: Includes built-in functions to save and load trained networks from files.

Related

  • Project
  • Project
  • Project
  • Project
  • Project