Struct easy_ml::differentiation::Derivatives
source · 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>
impl<T: Clone + Primitive> Derivatives<T>
sourcepub fn at_tensor_index<S, const D: usize>(
&self,
indexes: [usize; D],
input: &RecordTensor<'_, T, S, D>
) -> Option<T>
pub fn at_tensor_index<S, const D: usize>( &self, indexes: [usize; D], input: &RecordTensor<'_, T, S, D> ) -> Option<T>
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.
sourcepub fn at_tensor<S, const D: usize>(
&self,
input: &RecordTensor<'_, T, S, D>
) -> Tensor<T, D>
pub fn at_tensor<S, const D: usize>( &self, input: &RecordTensor<'_, T, S, D> ) -> Tensor<T, 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.
sourcepub fn at_matrix_index<S>(
&self,
row: Row,
column: Column,
input: &RecordMatrix<'_, T, S>
) -> Option<T>
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.
sourcepub fn at_matrix<S>(&self, input: &RecordMatrix<'_, T, S>) -> Matrix<T>
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.
Trait Implementations§
source§impl<T: Clone> Clone for Derivatives<T>
impl<T: Clone> Clone for Derivatives<T>
Any derivatives of a Cloneable type implements clone
source§impl<T: Debug> Debug for Derivatives<T>
impl<T: Debug> Debug for Derivatives<T>
source§impl<T> From<Derivatives<T>> for Vec<T>
impl<T> From<Derivatives<T>> for Vec<T>
source§fn from(derivatives: Derivatives<T>) -> Self
fn from(derivatives: Derivatives<T>) -> Self
Converts the Derivatives struct into a Vec of derivatives that
can be indexed with usize
s. The indexes correspond to the
index field on Records.