pub struct Var(/* private fields */);Implementations§
Source§impl Var
impl Var
Sourcepub fn leaf(t: Tensor) -> Var
pub fn leaf(t: Tensor) -> Var
A differentiable leaf (a parameter or input we want gradients for).
pub fn value(&self) -> &Tensor
pub fn grad(&self) -> Option<Tensor>
Sourcepub fn backward(&self)
pub fn backward(&self)
Backpropagate from this (scalar-ish) output: seed grad = ones, walk reverse-topo.
pub fn add(&self, o: &Var) -> Var
pub fn sub(&self, o: &Var) -> Var
pub fn mul(&self, o: &Var) -> Var
pub fn relu(&self) -> Var
pub fn neg(&self) -> Var
Sourcepub fn transpose(&self, a: usize, b: usize) -> Var
pub fn transpose(&self, a: usize, b: usize) -> Var
Transpose two dims; gradient transposes back.
pub fn div(&self, o: &Var) -> Var
pub fn exp(&self) -> Var
pub fn log(&self) -> Var
Sourcepub fn sum(&self, axes: &[usize]) -> Var
pub fn sum(&self, axes: &[usize]) -> Var
Sum over axes (keepdim); gradient broadcasts back to the input shape.
pub fn mean(&self, axes: &[usize]) -> Var
Sourcepub fn detach(&self) -> Var
pub fn detach(&self) -> Var
A non-differentiable copy (stop-gradient) — for the detached max in a stable softmax.
Sourcepub fn softmax(&self, axis: usize) -> Var
pub fn softmax(&self, axis: usize) -> Var
Numerically-stable softmax over axis, fully differentiable (built from primitives).
pub fn sum_all(&self) -> Var
pub fn mean_all(&self) -> Var
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Var
impl !Send for Var
impl !Sync for Var
impl !UnwindSafe for Var
impl Freeze for Var
impl Unpin for Var
impl UnsafeUnpin for Var
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