Leaf - Machine Learning for Hackers

Our life is frittered away by detail. Simplify, simplify. - Henry David Thoreau

This short book teaches you how you can build machine learning applications (with Leaf).

Leaf is a Machine Intelligence Framework engineered by hackers, not scientists. It has a very simple API consisting of Layers and Solvers, with which you can build classical machine as well as deep learning and other fancy machine intelligence applications. Although Leaf is just a few months old, thanks to Rust and Collenchyma it is already one of the fastest machine intelligence frameworks available.

Leaf was inspired by the brilliant people behind TensorFlow, Torch, Caffe, Rust and numerous research papers and brings modularity, performance and portability to deep learning.

To make the most of the book, a basic understanding of the fundamental concepts of machine and deep learning is recommended. Good resources to get you from zero to almost-ready-to-build-machine-learning-applications:

And if you already have some experience, A 'brief' history of Deep Learning or The Glossary might prove informative.

Both machine and deep learning are really easy with Leaf.

Construct a Network by chaining Layers. Then optimize the network by feeding it examples. This is why Leaf's entire API consists of only two concepts: Layers and Solvers. Use layers to construct almost any kind of model: deep, classical, stochastic or hybrids, and solvers for executing and optimizing the model.

This is already the entire API for machine learning with Leaf. To learn how this is possible and how to build machine learning applications, refer to chapters 2. Layers and 3. Solvers. Enjoy!


Leaf was built with three concepts in mind: accessibility/simplicity, performance and portability. We want developers and companies to be able to run their machine learning applications anywhere: on servers, desktops, smartphones and embedded devices. Any combination of platform and computation language (OpenCL, CUDA, etc.) is a first class citizen in Leaf.

We coupled portability with simplicity, meaning you can deploy your machine learning applications to almost any machine and device with no code changes. Learn more at chapter 4. Backend or at the Collenchyma Github repository.


Want to contribute? Awesome! We have instructions to help you get started.

Leaf has a near real-time collaboration culture, which happens at the Github repository and on the Leaf Gitter Channel.

API Documentation

Alongside this book you can also read the Rust API documentation if you would like to use Leaf as a crate, write a library on top of it or just want a more low-level overview.

> Rust API documentation


Leaf is free for anyone for whatever purpose. Leaf is licensed under either Apache License v2.0 or, MIT license. Whatever strikes your fancy.