A from-scratch C++ neural network training engine. No Python. No PyTorch dependency. Drop a single header into any C++ project and get a complete training pipeline.
Sandokan gives you classification, regression, custom datasets, optimizers, learning rate schedules, and model persistence — all backed by a custom slab allocator and Apple AMX acceleration.
Single header. Everything you need lives in <sandokan.h>. Submodule headers like sandokan/io.h and sandokan/inference.h extend the core.
Define your network, allocate the gradient slab, attach an optimizer, and call the training loop. Everything else is handled for you.
#include <sandokan.h>
struct LetterNet : Module {
Submodule<Linear> proj { *this, 784, 64 };
ReLU relu;
Submodule<Linear> head { *this, 64, 26 };
MatrixXf forward(const MatrixXf& x) override {
return head.forward(relu.forward(proj.forward(x)));
}
MatrixXf backward(const MatrixXf& dy) override {
return proj.backward(relu.backward(head.backward(dy)));
}
};
int main() {
LetterNet net;
init_pmad_for(net); // allocate gradient slab
ImageDataset train = load_emnist_letters("data/Emnist", true);
ImageDataset test = load_emnist_letters("data/Emnist", false);
train.compute_normalization();
test.apply_normalization_from(train);
Adam optim(1e-3f);
train_module(net, optim, train, test, 150, 128);
}