Skip to main content

Gradient

Trait Gradient 

Source
pub trait Gradient<T: Float>: Send + Sync {
    // Required methods
    fn grad(&self, x: ArrayView1<'_, T>) -> Array1<T>;
    fn dim(&self) -> usize;
}
Expand description

First-derivative interface. Types that know an analytic gradient implement this directly (or via DifferentiableObjective).

When only a black-box Objective is available, wrap it with FiniteDiffGradient. When a closure or Python grad callable is known, use AnalyticGradient (or construct a PyObjective with grad_fn).

Required Methods§

Source

fn grad(&self, x: ArrayView1<'_, T>) -> Array1<T>

Gradient of the underlying scalar field at x.

Source

fn dim(&self) -> usize

Number of input dimensions (must match the paired Objective::dim).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§