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

Computed derivatives of a computational graph for some output Record variable.

This can be indexed by any Record used in the computational graph to get the derivative with respect to that input.

Indexing using Records not involved in the computational graph, or involved in a different one will return nonsense or index out of bounds and panic. In the future this may be changed to always panic.

Implementations§

source§

impl<T: Clone + Primitive> Derivatives<T>

source

pub fn at_tensor_index<S, const D: usize>( &self, indexes: [usize; D], input: &RecordTensor<'_, T, S, D> ) -> Option<T>
where S: TensorRef<(T, Index), D>,

Queries the derivative at the provided index into the record tensor as input.

If you construct a Derivatives object for some output y, and call .at_tensor_index(i, &xs) on it for some input container xs and index i, this returns dy/dx where x = xs[i].

If the index into the tensor is invalid, returns None instead.

source

pub fn at_tensor<S, const D: usize>( &self, input: &RecordTensor<'_, T, S, D> ) -> Tensor<T, D>
where S: TensorRef<(T, Index), D>,

Queries the derivatives at every element in the record tensor input.

If you construct a Derivatives object for some output y, and call .at_tensor(&xs) on it for some input container xs this returns dy/dx for every x in xs.

source

pub fn at_matrix_index<S>( &self, row: Row, column: Column, input: &RecordMatrix<'_, T, S> ) -> Option<T>

Queries the derivative at the provided index into the record matrix as input.

If you construct a Derivatives object for some output y, and call .at_matrix_index(i, j, &xs) on it for some input container xs and indexes i and j, this returns dy/dx where x = xs[i, j].

If the index into the tensor is invalid, returns None instead.

source

pub fn at_matrix<S>(&self, input: &RecordMatrix<'_, T, S>) -> Matrix<T>

Queries the derivatives at every element in the record matrix input.

If you construct a Derivatives object for some output y, and call .at_matrix(&xs) on it for some input container xs this returns dy/dx for every x in xs.

source§

impl<T: Clone + Primitive> Derivatives<T>

source

pub fn at(&self, input: &Record<'_, T>) -> T

Quries the derivative at the provided record as input.

If you construct a Derivatives object for some output y, and call .at(&x) on it for some input x, this returns dy/dx.

Trait Implementations§

source§

impl<T: Clone> Clone for Derivatives<T>

Any derivatives of a Cloneable type implements clone

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Derivatives<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T> From<Derivatives<T>> for Vec<T>

source§

fn from(derivatives: Derivatives<T>) -> Self

Converts the Derivatives struct into a Vec of derivatives that can be indexed with usizes. The indexes correspond to the index field on Records.

source§

impl<'a, T: Primitive> Index<&Record<'a, T>> for Derivatives<T>

source§

fn index(&self, input: &Record<'a, T>) -> &Self::Output

Quries the derivative at the provided record as input.

If you construct a Derivatives object for some output y, and call .at(&x) on it for some input x, this returns dy/dx.

§

type Output = T

The returned type after indexing.

Auto Trait Implementations§

§

impl<T> Freeze for Derivatives<T>

§

impl<T> RefUnwindSafe for Derivatives<T>
where T: RefUnwindSafe,

§

impl<T> Send for Derivatives<T>
where T: Send,

§

impl<T> Sync for Derivatives<T>
where T: Sync,

§

impl<T> Unpin for Derivatives<T>
where T: Unpin,

§

impl<T> UnwindSafe for Derivatives<T>
where T: UnwindSafe,

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<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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.