Skip to content

MenxLi/mgrad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A minimal automatic scalar differentiation library.

All code are in a single file (src/mgrad.rs) to easily copy-paste into other projects.

use mgrad::nn;

fn main() {
    let x = nn::variable(1);
    let y = x.sin() + nn::constant(1);
    let y = (x.pow(2) * y).ln();
    y.backward(1);

    println!("dy/dx at x=1 is: {:?}", x.grad);
}

Run with cargo doc --open to see the documentation.
More examples can be found in the examples folder.

About

A minimal auto-differentiation engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages