Struct easy_ml::differentiation::WengertList[][src]

pub struct WengertList<T> { /* fields omitted */ }

A list of operations performed in a forward pass of a dynamic computational graph, used for Reverse Mode Automatic Differentiation.

This is dynamic, as in, you build the Wengert list at runtime by performing operations like addition and multiplication on Records that were created with that Wengert list.

When you perform a backward pass to obtain the gradients you travel back up the computational graph using the stored intermediate values from this list to compute all the gradients of the inputs and every intermediate step with respect to an output.

Although sophisticated implementations can make the Wengert list only log(N) in length by storing only some of the intermediate steps of N computational steps, this implementation is not as sophisticated, and will store all of them.

Panics

Every operation and nearly every method a Record has involves manipulating the record’s history on its referenced WengertList. This WengertList itself maintains a RefCell which tracks borrows at runtime rather than compile time. This is neccessary to maintain the illusion that Records are just ordinary numbers, and the side effects of doing arithmetic with Records are limited to their referenced WengertList. Hence, the Rust compiler infers that it is not safe to share references to WengertLists between threads, nor transfer Records across threads. If you called a method on two Records that both mutably borrowed from the same WengertList at once, which could be trivially done with multiple threads, then the code would panic. Easy ML shouldn’t allow you to do this in safe Rust because each mutable borrow of the WengertList is dropped at the end of each Record method call, and you can’t call two methods simulatenously without threading.

Implementations

impl<T: Primitive> WengertList<T>[src]

pub fn new() -> WengertList<T>[src]

Creates a new empty WengertList from which Records can be constructed.

impl<T> WengertList<T>[src]

pub fn clear(&self)[src]

Clears a WengertList to make it empty again. After clearing a WengertList you must reset all the Records still using that list. Then you can perform another computation and get new gradients.

impl<T: Numeric + Primitive> WengertList<T>[src]

pub fn variable(&self, x: T) -> Record<'_, T>[src]

Creates a record backed by this WengertList.

You can alternatively use the record constructor on the Record type.

Trait Implementations

impl<T: Clone + Primitive> Clone for WengertList<T>[src]

Any Wengert list of a Cloneable type implements clone

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for WengertList<T>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<T: Primitive> Default for WengertList<T>[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

Auto Trait Implementations

impl<T> !RefUnwindSafe for WengertList<T>

impl<T> Send for WengertList<T> where
    T: Send

impl<T> !Sync for WengertList<T>

impl<T> Unpin for WengertList<T> where
    T: Unpin

impl<T> UnwindSafe for WengertList<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.