pub struct OptimizerAdaptor<O, M, B>where
    O: SimpleOptimizer<B::InnerBackend>,
    M: AutodiffModule<B>,
    B: AutodiffBackend,{ /* private fields */ }
Expand description

Wrapper struct that adapts any simple optimizer into an optimizer.

Implementations§

source§

impl<O, M, B> OptimizerAdaptor<O, M, B>where O: SimpleOptimizer<B::InnerBackend>, M: AutodiffModule<B>, B: AutodiffBackend,

source

pub fn with_grad_clipping(self, gradient_clipping: GradientClipping) -> Self

Sets the gradient clipping.

Arguments
  • gradient_clipping - The gradient clipping.
Returns

The optimizer.

Trait Implementations§

source§

impl<O, B, M> From<O> for OptimizerAdaptor<O, M, B>where B: AutodiffBackend, M: AutodiffModule<B>, O: SimpleOptimizer<B::InnerBackend>,

source§

fn from(optim: O) -> Self

Converts to this type from the input type.
source§

impl<O, B, M> Optimizer<M, B> for OptimizerAdaptor<O, M, B>where B: AutodiffBackend, M: AutodiffModule<B>, O: SimpleOptimizer<B::InnerBackend>,

§

type Record = HashMap<ParamId, AdaptorRecord<O, <B as AutodiffBackend>::InnerBackend>>

Optimizer associative type to be used when saving and loading the state.
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.

Auto Trait Implementations§

§

impl<O, M, B> RefUnwindSafe for OptimizerAdaptor<O, M, B>where M: RefUnwindSafe, O: RefUnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<1>: RefUnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<2>: RefUnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<3>: RefUnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<4>: RefUnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<5>: RefUnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<6>: RefUnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<7>: RefUnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<8>: RefUnwindSafe,

§

impl<O, M, B> Send for OptimizerAdaptor<O, M, B>

§

impl<O, M, B> Sync for OptimizerAdaptor<O, M, B>

§

impl<O, M, B> Unpin for OptimizerAdaptor<O, M, B>where M: Unpin, O: Unpin, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<1>: Unpin, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<2>: Unpin, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<3>: Unpin, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<4>: Unpin, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<5>: Unpin, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<6>: Unpin, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<7>: Unpin, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<8>: Unpin,

§

impl<O, M, B> UnwindSafe for OptimizerAdaptor<O, M, B>where M: UnwindSafe, O: UnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<1>: UnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<2>: UnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<3>: UnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<4>: UnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<5>: UnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<6>: UnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<7>: UnwindSafe, <O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<8>: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V