Skip to main content

Var

Struct Var 

Source
pub struct Var(/* private fields */);

Implementations§

Source§

impl Var

Source

pub fn leaf(t: Tensor) -> Var

A differentiable leaf (a parameter or input we want gradients for).

Source

pub fn value(&self) -> &Tensor

Source

pub fn grad(&self) -> Option<Tensor>

Source

pub fn backward(&self)

Backpropagate from this (scalar-ish) output: seed grad = ones, walk reverse-topo.

Source

pub fn add(&self, o: &Var) -> Var

Source

pub fn sub(&self, o: &Var) -> Var

Source

pub fn mul(&self, o: &Var) -> Var

Source

pub fn matmul(&self, o: &Var) -> Var

Matmul (last two dims; equal or absent batch dims).

Source

pub fn relu(&self) -> Var

Source

pub fn neg(&self) -> Var

Source

pub fn transpose(&self, a: usize, b: usize) -> Var

Transpose two dims; gradient transposes back.

Source

pub fn div(&self, o: &Var) -> Var

Source

pub fn exp(&self) -> Var

Source

pub fn log(&self) -> Var

Source

pub fn sum(&self, axes: &[usize]) -> Var

Sum over axes (keepdim); gradient broadcasts back to the input shape.

Source

pub fn mean(&self, axes: &[usize]) -> Var

Source

pub fn detach(&self) -> Var

A non-differentiable copy (stop-gradient) — for the detached max in a stable softmax.

Source

pub fn softmax(&self, axis: usize) -> Var

Numerically-stable softmax over axis, fully differentiable (built from primitives).

Source

pub fn sum_all(&self) -> Var

Source

pub fn mean_all(&self) -> Var

Trait Implementations§

Source§

impl Clone for Var

Source§

fn clone(&self) -> Var

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>