pub struct Adam {
pub learning_rate: LearningRate,
pub betas: (f64, f64),
pub eps: f64,
pub bias_correction: bool,
pub weight_decay: f64,
/* private fields */
}Expand description
Adam, as MLX’s optimizers.Adam (bias correction off unless enabled, as in MLX), and
AdamW (decoupled weight decay) with Adam::weight_decay.
Fields§
§learning_rate: LearningRateThe learning rate.
betas: (f64, f64)Decay rates of the first and second moment estimates.
eps: f64Added to the denominator for numerical stability.
bias_correction: boolWhether to correct the moment estimates’ bias toward zero.
weight_decay: f64Decoupled weight decay (AdamW); 0 for Adam.
Implementations§
Source§impl Adam
impl Adam
Sourcepub fn new(learning_rate: impl Into<LearningRate>) -> Self
pub fn new(learning_rate: impl Into<LearningRate>) -> Self
Adam with betas (0.9, 0.999) and eps = 1e-8.
Sourcepub fn adamw(learning_rate: impl Into<LearningRate>) -> Self
pub fn adamw(learning_rate: impl Into<LearningRate>) -> Self
AdamW, as MLX’s optimizers.AdamW: Adam with decoupled weight decay (default
0.01).
Sourcepub fn weight_decay(self, weight_decay: f64) -> Self
pub fn weight_decay(self, weight_decay: f64) -> Self
Sets the decoupled weight decay (AdamW).
Sourcepub fn bias_correction(self, enabled: bool) -> Self
pub fn bias_correction(self, enabled: bool) -> Self
Enables bias correction.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Adam
impl !UnwindSafe for Adam
impl Freeze for Adam
impl Send for Adam
impl Sync for Adam
impl Unpin for Adam
impl UnsafeUnpin for Adam
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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