Module corgi::array[][src]

An n-dimensional array, with automatic differentation.

Examples

See the README for more examples.

use corgi::array::*;

let a = arr![5.0].tracked();
let b = arr![2.0].tracked();
let mut c = arr![0.0].tracked();

for _ in 0..10 {
    c = &c + &(&a * &b);
    if c[0] > 50.0 {
        c = &c * &a;
    }
}

c.backward(None);
assert_eq!(c, arr![195300.0]);
assert_eq!(c.gradient().unwrap(), arr![1.0]);
assert_eq!(b.gradient().unwrap(), arr![97650.0]);
assert_eq!(a.gradient().unwrap(), arr![232420.0]);

Structs

Array

An n-dimensional differentiable array. Stored in row-major order.

Traits

Arrays

Helper trait to construct Array structs.

Type Definitions

BackwardOp

The backward operation computes deltas with respect to inputs.

ForwardOp

The forward operation computes an operation with respect to inputs.