Trait Optimizer

Source
pub trait Optimizer<M, B>: Send{
    type Record: Record<B>;

    // Required methods
    fn step(&mut self, lr: LearningRate, module: M, grads: GradientsParams) -> M;
    fn to_record(&self) -> Self::Record;
    fn load_record(self, record: Self::Record) -> Self;
}
Expand description

General trait to optimize module.

Required Associated Types§

Source

type Record: Record<B>

Optimizer associative type to be used when saving and loading the state.

Required Methods§

Source

fn step(&mut self, lr: LearningRate, module: M, grads: GradientsParams) -> M

Perform the optimizer step using the given learning rate and gradients. The updated module is returned.

Source

fn to_record(&self) -> Self::Record

Get the current state of the optimizer as a record.

Source

fn load_record(self, record: Self::Record) -> Self

Load the state of the optimizer as a record.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§