pub struct AdamW { /* private fields */ }Expand description
AdamW optimizer (Loshchilov & Hutter, 2019).
Like Adam but with decoupled weight decay, which is more effective for regularization.
The key difference from Adam:
param = param - lr * weight_decay * param // Decoupled weight decay
param = param - lr * m̂_t / (√v̂_t + ε) // Then Adam updateImplementations§
Source§impl AdamW
impl AdamW
Sourcepub fn new(params: Vec<&mut Tensor>, lr: f32) -> Self
pub fn new(params: Vec<&mut Tensor>, lr: f32) -> Self
Create a new AdamW optimizer.
Default: β₁=0.9, β₂=0.999, ε=1e-8, weight_decay=0.01
pub fn betas(self, beta1: f32, beta2: f32) -> Self
pub fn eps(self, eps: f32) -> Self
pub fn weight_decay(self, wd: f32) -> Self
pub fn step_with_params(&mut self, params: &mut [&mut Tensor])
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AdamW
impl RefUnwindSafe for AdamW
impl Send for AdamW
impl Sync for AdamW
impl Unpin for AdamW
impl UnsafeUnpin for AdamW
impl UnwindSafe for AdamW
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> 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