Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 1002 Bytes

README.md

File metadata and controls

31 lines (23 loc) · 1002 Bytes

revad: Reverse-mode automatic differentiation demo

This is a demonstration of how gradients could be calculated using reverse-mode automatic differentiation.

let t = Tape::new();
let x = t.var(0.5);
let y = t.var(4.2);
let z = x * y + x.sin();
let grad = z.grad();
println!("z = {}", z.value);         // z = 2.579425538604203
println!("∂z/∂x = {}", grad.wrt(x)); // ∂z/∂x = 5.077582561890373
println!("∂z/∂y = {}", grad.wrt(y)); // ∂z/∂y = 0.5

This library is an experiment/demonstration/prototype and is therefore woefully incomplete. Feel free to use its ideas to build an actual AD library!

Usage

Add this to your Cargo.toml:

[dependencies]
revad = { git = "https://github.com/Rufflewind/revad" }

and add this line to the root module of your crate:

extern crate revad;