pub struct Gradients<T> { /* private fields */ }Expand description
The gradients computed by Var::backward.
Query individual gradients using get.
§Example
use autodiff::Tape;
let tape = Tape::new();
let x = tape.var(3.0);
let y = tape.var(4.0);
let z = x.clone() * y.clone(); // z = x * y
let grads = z.backward();
assert_eq!(grads.get(&x), 4.0); // dz/dx = y
assert_eq!(grads.get(&y), 3.0); // dz/dy = xImplementations§
Auto Trait Implementations§
impl<T> Freeze for Gradients<T>
impl<T> !RefUnwindSafe for Gradients<T>
impl<T> !Send for Gradients<T>
impl<T> !Sync for Gradients<T>
impl<T> Unpin for Gradients<T>
impl<T> !UnwindSafe for Gradients<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more