pub struct AdamW<B>(pub Adam<B>)
where
B: Backend;Expand description
AdamW optimizer (Adam with decoupled weight decay).
This is the standard optimizer for training Transformers. The key difference from Adam: weight decay is applied directly to the parameters, not mixed into the gradient.
Tuple Fields§
§0: Adam<B>Implementations§
Source§impl<B> AdamW<B>where
B: Backend,
impl<B> AdamW<B>where
B: Backend,
Sourcepub fn new(params: Vec<Tensor<B>>, lr: f64, weight_decay: f64) -> AdamW<B>
pub fn new(params: Vec<Tensor<B>>, lr: f64, weight_decay: f64) -> AdamW<B>
Create an AdamW optimizer with standard defaults.
Default: lr=1e-3, β1=0.9, β2=0.999, ε=1e-8, weight_decay=0.01
Sourcepub fn weight_decay(self, wd: f64) -> AdamW<B>
pub fn weight_decay(self, wd: f64) -> AdamW<B>
Set weight decay.
Sourcepub fn params_mut(&mut self) -> &mut Vec<Tensor<B>>
pub fn params_mut(&mut self) -> &mut Vec<Tensor<B>>
Mutable access to current parameters (for checkpoint loading).
Trait Implementations§
Source§impl<B> Stateful for AdamW<B>where
B: Backend,
impl<B> Stateful for AdamW<B>where
B: Backend,
Source§fn state_dict(&self) -> OptimizerState
fn state_dict(&self) -> OptimizerState
Export the optimizer’s internal state as a serializable dictionary.
Source§fn load_state_dict(&mut self, state: &OptimizerState) -> Result<(), Error>
fn load_state_dict(&mut self, state: &OptimizerState) -> Result<(), Error>
Restore the optimizer’s internal state from a previously saved dictionary. Read more
Auto Trait Implementations§
impl<B> Freeze for AdamW<B>
impl<B> RefUnwindSafe for AdamW<B>
impl<B> Send for AdamW<B>
impl<B> Sync for AdamW<B>
impl<B> Unpin for AdamW<B>
impl<B> UnwindSafe for AdamW<B>
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