pub struct WengertList<T> { /* private fields */ }
Expand description

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

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

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.

Creates a record backed by this WengertList.

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

Trait Implementations

Any Wengert list of a Cloneable type implements clone

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.