mgrad 0.1.5

A minimal automatic differentiation library.
Documentation
use mgrad::nn;

fn main() {
    let x = nn::variable(1);
    let y = nn::variable(2);
    let m = &x + &y;
    let z = &m.sin() + &m.cos();
    z.abs().backward(1);

    // Capture the graph up to z, 
    // and print it in graphviz format
    let mut g = nn::Graph::from_trace(&z).unwrap();
    println!("{}", g.to_graphviz());

    // Perform gradient descent, 
    // follow the graph to re-calculate z
    let z_value_record = z.value;
    let step = 1e-3;
    g.apply_grad(-step);
    g.forward();
    assert!(z.value.abs() < z_value_record.abs());
}