Skip to content
forked from Rufflewind/revad

Reverse-mode automatic differentiation in Rust (experiment)

License

Notifications You must be signed in to change notification settings

rhettinger/revad

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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;

About

Reverse-mode automatic differentiation in Rust (experiment)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 83.6%
  • Haskell 11.6%
  • Python 4.8%