Usul-cpp

Explore how Usul turns complex neural networks into simple math

If you're tired of treating neural networks like black boxes summoned by opaque frameworks, Usul-cpp offers a refreshing alternative.

4 min readMachine Learning

The most honest thing you can say about neural networks is that they are math. The rest is packaging. Usul-cpp, a new C++ library from a developer who taught himself matrix calculus with pen and paper, strips that packaging away and lets you work directly with the equations. It is a small, focused project that does one thing well: you write the forward pass as arithmetic, and the library handles automatic differentiation, backpropagation, and gradient descent. The XOR example in the repository is not a demo; it is the entire philosophy. Define your tensors, write your layers as matrix multiplications and activations, call `.backwards()` and `.step()`, and watch the loss fall. No black boxes. No sprawling framework dependencies. Just the math you wrote, executing.

This approach matters because it addresses a real friction point that many data scientists feel but rarely name. Heavy libraries like TensorFlow or PyTorch abstract the mathematics so thoroughly that the underlying operations become opaque. You call a layer class, you get a result, but the connection between the code and the calculus is lost. As the developer notes, reading math is less mystifying than reading a random class that supposedly does something. That insight resonates with a pattern we have seen elsewhere. In When Simpler Tools Match Advanced AI on Intent Classification, we covered how lightweight approaches can rival heavyweight models when the problem is well-understood. And in Revisiting Batch Normalization: Why It Worked and Why We Moved On, we saw that even established techniques benefit from being re-examined at the mathematical level rather than accepted as framework defaults. Usul-cpp takes that principle to its logical endpoint: if you understand the math, you should be able to write it.

The library is built on xtensor for precision, written in C++23, and designed to be memory safe. It is lightweight by necessity. The developer wrote it partly as a detox from LLM dependency, a deliberate exercise in rebuilding understanding from first principles. That is not a criticism of AI tools; it is a recognition that fluency in the fundamentals matters. The result is a library that does not try to do everything but makes what it does do transparent. You can see the gradient flow. You can trace the loss back to the weights that produced it. That transparency is valuable for learning, for debugging, and for confidence in your models.

The concrete takeaway here is that Usul-cpp is worth exploring if you have ever felt that your framework is doing too much for you. It is not a replacement for production-scale deep learning. It is a tool for understanding, for prototyping, and for building models where you want to see every step. The developer is open to contributions and ideas, and the project is small enough that a motivated user could extend it in meaningful directions. Watch what happens when more people start writing their neural networks as math again. That shift, small as it may seem, changes how you think about what the tools are doing for you, and what you could be doing yourself.

From Machine Learning

SO, Usul-cpp is a library I've written in C++, it is based around allowing data scientists to create their models without heavy libraries such as tensorflow, and just express their models using maths, and Usul will handle the rest. There is builtin tensor support, auto-grad, back-prop and its quite fast.

I wrote it because, it seemed less mystifying to read maths instead of a random class that supposedly does something. I wrote it from scratch in cpp (23) due to the fact that I wanted to emphasise on precision, however it's subtly built on top of `xtensor`.

Read the original at Machine Learning