Struct burn::optim::adaptor::OptimizerAdaptor
pub struct OptimizerAdaptor<O, M, B>where
O: SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
M: AutodiffModule<B>,
B: AutodiffBackend,{ /* private fields */ }
Expand description
Wrapper struct that adapts any simple optimizer into an optimizer.
Implementations§
§impl<O, M, B> OptimizerAdaptor<O, M, B>where
O: SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
M: AutodiffModule<B>,
B: AutodiffBackend,
impl<O, M, B> OptimizerAdaptor<O, M, B>where
O: SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
M: AutodiffModule<B>,
B: AutodiffBackend,
pub fn with_grad_clipping(
self,
gradient_clipping: GradientClipping,
) -> OptimizerAdaptor<O, M, B>
pub fn with_grad_clipping( self, gradient_clipping: GradientClipping, ) -> OptimizerAdaptor<O, M, B>
Trait Implementations§
§impl<O, M, B> Clone for OptimizerAdaptor<O, M, B>where
O: Clone + SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
M: Clone + AutodiffModule<B>,
B: Clone + AutodiffBackend,
impl<O, M, B> Clone for OptimizerAdaptor<O, M, B>where
O: Clone + SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
M: Clone + AutodiffModule<B>,
B: Clone + AutodiffBackend,
§fn clone(&self) -> OptimizerAdaptor<O, M, B>
fn clone(&self) -> OptimizerAdaptor<O, M, B>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl<O, B, M> From<O> for OptimizerAdaptor<O, M, B>where
B: AutodiffBackend,
M: AutodiffModule<B>,
O: SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
impl<O, B, M> From<O> for OptimizerAdaptor<O, M, B>where
B: AutodiffBackend,
M: AutodiffModule<B>,
O: SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
§fn from(optim: O) -> OptimizerAdaptor<O, M, B>
fn from(optim: O) -> OptimizerAdaptor<O, M, B>
Converts to this type from the input type.
§impl<O, B, M> Optimizer<M, B> for OptimizerAdaptor<O, M, B>where
B: AutodiffBackend,
M: AutodiffModule<B>,
O: SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
impl<O, B, M> Optimizer<M, B> for OptimizerAdaptor<O, M, B>where
B: AutodiffBackend,
M: AutodiffModule<B>,
O: SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>,
§type Record = HashMap<ParamId, AdaptorRecord<O, B>>
type Record = HashMap<ParamId, AdaptorRecord<O, B>>
Optimizer associative type to be used when saving and loading the state.
§fn step(&mut self, lr: f64, module: M, grads: GradientsParams) -> M
fn step(&mut self, lr: f64, module: M, grads: GradientsParams) -> M
Perform the optimizer step using the given learning rate and gradients.
The updated module is returned.
§fn to_record(&self) -> <OptimizerAdaptor<O, M, B> as Optimizer<M, B>>::Record
fn to_record(&self) -> <OptimizerAdaptor<O, M, B> as Optimizer<M, B>>::Record
Get the current state of the optimizer as a record.
§fn load_record(
self,
record: <OptimizerAdaptor<O, M, B> as Optimizer<M, B>>::Record,
) -> OptimizerAdaptor<O, M, B>
fn load_record( self, record: <OptimizerAdaptor<O, M, B> as Optimizer<M, B>>::Record, ) -> OptimizerAdaptor<O, M, B>
Load the state of the optimizer as a record.
Auto Trait Implementations§
impl<O, M, B> Freeze for OptimizerAdaptor<O, M, B>where
O: Freeze,
impl<O, M, B> RefUnwindSafe for OptimizerAdaptor<O, M, B>where
O: RefUnwindSafe,
M: RefUnwindSafe,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<0>: 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>where
M: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<0>: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<1>: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<2>: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<3>: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<4>: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<5>: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<6>: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<7>: Sync,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<8>: Sync,
impl<O, M, B> Unpin for OptimizerAdaptor<O, M, B>where
O: Unpin,
M: Unpin,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<0>: 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
O: UnwindSafe,
M: UnwindSafe,
<O as SimpleOptimizer<<B as AutodiffBackend>::InnerBackend>>::State<0>: 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more