Skip to content

Rufflewind/revad

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

Fix private field `value` to public method `value()`
687df5f

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
January 1, 2017 20:30
src
January 3, 2017 20:55
December 30, 2016 08:25
December 30, 2016 08:25
January 1, 2017 20:30
January 24, 2021 22:53
January 3, 2017 20:55
December 30, 2016 13:52

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)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published