pub struct Adam { /* private fields */ }Expand description
Adam optimizer (Adaptive Moment Estimation).
Combines momentum with adaptive learning rates per parameter.
§Mathematical Description
$$m_t = \beta_1 m_{t-1} + (1-\beta_1) g_t$$ $$v_t = \beta_2 v_{t-1} + (1-\beta_2) g_t^2$$ $$\hat{m}_t = m_t / (1 - \beta_1^t)$$ $$\hat{v}t = v_t / (1 - \beta_2^t)$$ $$\theta_t = \theta{t-1} - \alpha \hat{m}_t / (\sqrt{\hat{v}_t} + \epsilon)$$
§Example
use logosq_optimizer::Adam;
let optimizer = Adam::new()
.with_learning_rate(0.001)
.with_beta1(0.9)
.with_beta2(0.999);Implementations§
Source§impl Adam
impl Adam
Sourcepub fn with_learning_rate(self, lr: f64) -> Self
pub fn with_learning_rate(self, lr: f64) -> Self
Set the learning rate.
Sourcepub fn with_beta1(self, beta1: f64) -> Self
pub fn with_beta1(self, beta1: f64) -> Self
Set beta1 (first moment decay).
Sourcepub fn with_beta2(self, beta2: f64) -> Self
pub fn with_beta2(self, beta2: f64) -> Self
Set beta2 (second moment decay).
Sourcepub fn with_epsilon(self, epsilon: f64) -> Self
pub fn with_epsilon(self, epsilon: f64) -> Self
Set epsilon for numerical stability.
Sourcepub fn with_gradient_clip(self, max_norm: f64) -> Self
pub fn with_gradient_clip(self, max_norm: f64) -> Self
Enable gradient clipping.
Sourcepub fn minimize<F: ObjectiveFunction>(
&self,
objective: &F,
initial_params: &[f64],
criteria: &ConvergenceCriteria,
) -> Result<OptimizationResult, OptimizerError>
pub fn minimize<F: ObjectiveFunction>( &self, objective: &F, initial_params: &[f64], criteria: &ConvergenceCriteria, ) -> Result<OptimizationResult, OptimizerError>
Minimize an objective function.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Adam
impl RefUnwindSafe for Adam
impl Send for Adam
impl Sync for Adam
impl Unpin for Adam
impl UnwindSafe 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