Skip to main content

Optimizer

Trait Optimizer 

Source
pub trait Optimizer:
    Send
    + Sync
    + Display {
    // Required method
    fn optimize(
        &self,
        function: &dyn Fn(&Tensor) -> Tensor,
        x0: &Tensor,
    ) -> Result<Tensor>;
}
Expand description

Optimizer interface common for any optimizer in the library

Required Methods§

Source

fn optimize( &self, function: &dyn Fn(&Tensor) -> Tensor, x0: &Tensor, ) -> Result<Tensor>

Solves the problem of optimization of function function starting from point x0

§Arguments
  • function - A closure that takes a 1D tensor x and returns a scalar tensor. representing the objective value to minimize.
  • x0 - Initial guess, 1D tensor accepted by function.
§Returns

Optimal x, or error if optimization fails.

§Panics

May panic if libtorch tensor operations fail.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§