SHOW RN
Show RN: Tiny scalar-valued autograd engine supporting reverse-mode autodiff in Rust
Why I built this
I wanted to deeply understand how PyTorch and Micrograd calculate backpropagation gradients on a computational DAG, so I wrote a minimal scalar autograd engine in Rust from scratch without external crates.
Key Features
Rc<RefCell<Node>>.tanh, relu, and pow.rust
let x = Value::from(2.0);
let y = Value::from(3.0);
let mut z = &x * &y + &x;
z.backward();
println!("dz/dx = {}", x.grad()); // prints 4.0
Feedback on safe Rust memory management for cyclic graphs appreciated!
0 Discussions
Join Technical Discussion
Threaded Responses (0)
No replies yet. Be the first to share an engineering perspective.