Skip to content

mtortonesi/maurograd

Repository files navigation

Maurograd

Maurograd is my take on creating a framwork for Artificial Neural Networks (ANNs) in the Ruby programming language.

It started as an exercise to develop a clone of Andrej Karpathy's micrograd but it almost immediately became something more ambitious. I wanted to add support for Convolutional Neural Networks (CNNs) and to have a reasonably CPU-competent framework. So, after many experiments (and the corresponding performance evaluations) I ended up with a relatively clean mostly-Ruby codebase that leverages numo-narray-alt as a tensor framwork and implements 2D convolution in C using the im2col + GEMM + col2im approach. For simplicity, GEMM is performed with OpenBLAS. (In general, I hate the idea of developing C extensions for Ruby, but they are perfect for this task.)

Examples

While a full documentation will come down the road, Maurograd comes with two ANN classifier examples that should explain how to use the framework: an MLP classifier for the two moons dataset (along with a script to generate the corresponding dataset) and a multi-class classifier for the digit recognition on the MNIST datase based on the LeNet CNN architecture.

Disclaimers

At its heart, Maurograd is a didactic project. It is designed to be as simple as possible, while reasonably CPU-competent. The project's goal is to enable students to easily understand the inner working of serious ANN framework, by leveraging Ruby's expressiveness and readability. So, Maurograd is not a state-of-the-art ANN solution from the performance point of view - and never will be. If you have a performance-oriented focus, you will be much better server by torch.rb or (if you are on Apple silicon) mlx-ruby.

In addition, while developing Maurograd I heavily used AI-assisted coding solutions. A secondary goal of this project for me was to familiarize with state-of-the-art AI coding tools. I am completely open and unapologetic about this. Of course, I ended up revising most of the code generated by AI. I would guess that at the time of this writing (2026) the majority of software project are being developed with a similar approach.

License

This software is available as open source under the terms of the MIT License.

About

My take on creating a micrograd-inspired tiny ANN library in Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors