autograd
This library provides differentiable operations and tensors. The current backend is rust-ndarray.
Examples
Here we are computing partial derivatives of z = 2x^2 + 3y + 1
.
extern crate ndarray;
extern crate autograd as ag;
let ref x = placeholder;
let ref y = placeholder;
let ref z = 2*x*x + 3*y + 1;
// dz/dy
let ref g1 = grad;
// dz/dx
let ref g2 = grad;
// ddz/dx (differentiates `z` again)
let ref gg = grad;
// evaluation of symbolic gradients
let mut ctx = new;
println!; // => 3.
println!; // => 4.
// dz/dx requires to fill the placeholder `x`
feed_input;
println!; // => 8.
Another example: multi layer perceptron for MNIST digits classification.
// -- graph def --
let mut ctx = new;
let ref x = placeholder;
let ref y = placeholder;
let ref w = variable;
let ref b = variable;
let ref z = matmul + b;
let ref loss = sparse_softmax_cross_entropy;
let ref grads = grad;
let ref predictions = argmax;
let ref accuracy = reduce_mean;
// -- dataset --
let = load;
// -- training method --
let mut optimizer = SGD ;
// -- training loop --
for epoch in 0..max_epoch
For more, see examples or tests.
Available ops are listed here.