Neural nets for machines that can't spare a dependency
A single-header C99 library that trains feedforward networks without dragging in Python, CMake, or your sanity.

What it does
Cranium is a header-only feedforward neural network library in plain C99. Copy the src directory, #include "cranium.h", link -lm, and you have fully-connected networks with backprop, SGD variants, L2 regularization, and serialization. It targets embedded systems and restricted environments where installing dependencies is a non-starter.
The interesting bit
The BLAS integration is almost apologetically minimal: uncomment line 7 in matrix.h to swap in sgemm. No build system gymnastics, no feature flags — just a literal line comment. The whole API is raw C pointers and manual create/destroy calls, which feels archaic until you remember where this is meant to run.
Key highlights
- Header-only: drop-in
srcfolder, no build configuration - Supports sigmoid, ReLU, tanh, softmax, linear activations
- Cross-entropy and MSE loss with batch/mini-batch/stochastic gradient descent
- L2 regularization, momentum, learning rate annealing, fan-in initialization
- Network serialization to disk (
saveNetwork/readNetwork) - Optional CBLAS acceleration via single
#definetoggle
Caveats
- Only feedforward architectures; no CNNs, RNNs, or attention
- Manual memory management throughout (
destroyNetwork,destroyDataSet) - Last meaningful commit activity appears to be years ago; Travis CI badge suggests legacy maintenance
Verdict
Grab this if you’re shipping inference on a microcontroller or maintaining legacy C codebases that need a neural net without the ecosystem tax. Skip it if you need modern architectures, automatic differentiation, or GPU acceleration — this is a deliberately narrow tool for narrow constraints.