← all repositories
raskr/rust-autograd

TensorFlow-style autograd for the borrow-checker crowd

A Rust-native automatic differentiation library that builds computation graphs without drowning in heap allocations.

502 stars Rust ML Frameworks
rust-autograd
Velocity · 7d
+0.2
★ / day
Trend
steady
star history

What it does

rust-autograd gives you tensors and reverse-mode automatic differentiation in Rust, backed by the ndarray crate. You define a computation graph, run forward passes, and compute gradients — the usual deep-learning primitives, just with ownership semantics.

The interesting bit

The library deliberately apes TensorFlow/Theano’s low-level feel: placeholders, variables, explicit Context objects, even an Adam optimizer. The pitch is that computation graphs need “only bare minimum of heap allocations,” which matters when you’re trying to train networks without a garbage collector. There’s also a neat Tensor::map() escape hatch that lets you drop into raw ndarray operations mid-graph.

Key highlights

  • Reverse-mode autograd with second-order derivatives (the README demos ddz/dx)
  • Optional BLAS acceleration via accelerate, intel-mkl, or openblas
  • VariableEnvironment for managing trainable parameters across epochs
  • Hooks and map() for debugging or bridging to ndarray directly
  • MNIST MLP example clocks 0.11 sec/epoch on a 2.7GHz i5 (author’s hardware, unverified)

Caveats

  • The MNIST example in the README is incomplete: the actual data feeding and adam.update() call are commented out, so copy-pasting won’t train anything
  • 502 stars suggests a small community; expect to read source for edge cases

Verdict

Worth a look if you want autograd in Rust without pulling in a framework the size of PyTorch or TensorFlow. Skip it if you need battle-tested GPU acceleration or high-level Keras-style APIs — this is closer to building graphs by hand.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.