pub struct BurnOptimizer<B, M, O>{ /* private fields */ }Expand description
Burn-side optimizer wrapper.
Wraps a Burn OptimizerAdaptor<O, M, B> and exposes it through the
BackendOptimizer trait. The trainer bodies hold one of these and
route their gradient step through BackendOptimizer::step_module.
Implementations§
Source§impl<B, M, O> BurnOptimizer<B, M, O>
impl<B, M, O> BurnOptimizer<B, M, O>
Sourcepub fn new(inner: O, learning_rate: f64) -> Self
pub fn new(inner: O, learning_rate: f64) -> Self
Wrap a Burn optimizer (typically AdamConfig::new().init()).
Sourcepub fn inner_mut(&mut self) -> &mut O
pub fn inner_mut(&mut self) -> &mut O
Mutably borrow the wrapped Burn optimizer. The trainer bodies
call inner_mut().step(lr, module, grads) directly from their
loss closures.
Sourcepub fn grad_clip_norm(&self) -> Option<f64>
pub fn grad_clip_norm(&self) -> Option<f64>
The currently-staged gradient-norm cap, if any.
Trait Implementations§
Source§impl<B, M, O> BackendOptimizer for BurnOptimizer<B, M, O>
impl<B, M, O> BackendOptimizer for BurnOptimizer<B, M, O>
Source§fn clip_grad_norm(&mut self, max: f64)
fn clip_grad_norm(&mut self, max: f64)
Stage the maximum global gradient L2-norm. Read more
Source§fn step_module(&mut self, module: Self::Module) -> Self::Module
fn step_module(&mut self, module: Self::Module) -> Self::Module
Burn-style move-through update. Read more
Source§fn learning_rate(&self) -> f64
fn learning_rate(&self) -> f64
Construction-time learning rate. Exposed for diagnostics.
Source§impl<B, M, O> Debug for BurnOptimizer<B, M, O>
impl<B, M, O> Debug for BurnOptimizer<B, M, O>
Auto Trait Implementations§
impl<B, M, O> Freeze for BurnOptimizer<B, M, O>where
O: Freeze,
impl<B, M, O> RefUnwindSafe for BurnOptimizer<B, M, O>
impl<B, M, O> Send for BurnOptimizer<B, M, O>
impl<B, M, O> Sync for BurnOptimizer<B, M, O>
impl<B, M, O> Unpin for BurnOptimizer<B, M, O>
impl<B, M, O> UnsafeUnpin for BurnOptimizer<B, M, O>where
O: UnsafeUnpin,
impl<B, M, O> UnwindSafe for BurnOptimizer<B, M, O>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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