pub trait DifferentiableArray: ArrayProtocol {
// Required methods
fn gradient(
&self,
variables: &[Box<dyn DifferentiableArray>],
) -> Vec<Box<dyn DifferentiableArray>>;
fn set_requiresgrad(&mut self, requiresgrad: bool);
fn requiresgrad(&self) -> bool;
fn grad(&self) -> Option<Box<dyn DifferentiableArray>>;
}
Expand description
Trait for arrays that support automatic differentiation.
Required Methods§
Sourcefn gradient(
&self,
variables: &[Box<dyn DifferentiableArray>],
) -> Vec<Box<dyn DifferentiableArray>>
fn gradient( &self, variables: &[Box<dyn DifferentiableArray>], ) -> Vec<Box<dyn DifferentiableArray>>
Compute the gradient of this array with respect to some variables.
Sourcefn set_requiresgrad(&mut self, requiresgrad: bool)
fn set_requiresgrad(&mut self, requiresgrad: bool)
Set whether to record operations for automatic differentiation.
Sourcefn requiresgrad(&self) -> bool
fn requiresgrad(&self) -> bool
Check if this array requires gradient computation.
Sourcefn grad(&self) -> Option<Box<dyn DifferentiableArray>>
fn grad(&self) -> Option<Box<dyn DifferentiableArray>>
Get the gradient of this array.