Module corgi::array [−][src]
Expand description
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().to_owned().unwrap(), arr![1.0]);
assert_eq!(b.gradient().to_owned().unwrap(), arr![97650.0]);
assert_eq!(a.gradient().to_owned().unwrap(), arr![232420.0]);
Structs
An n-dimensional differentiable array. Stored in row-major order.
Type Definitions
The backward operation computes deltas with respect to inputs.
The forward operation computes an operation with respect to inputs.