pub struct Lamb { /* private fields */ }Expand description
Layer-wise Adaptive Moments optimizer for Batch training (LAMB).
Combines Adam-style adaptive moment estimation with layer-wise trust ratio scaling for stable large-batch training.
Implementations§
Source§impl Lamb
impl Lamb
Sourcepub fn new(lr: f32) -> Result<Self, OptimError>
pub fn new(lr: f32) -> Result<Self, OptimError>
Creates LAMB with required learning rate.
Sourcepub fn with_betas(self, beta1: f32, beta2: f32) -> Result<Self, OptimError>
pub fn with_betas(self, beta1: f32, beta2: f32) -> Result<Self, OptimError>
Sets beta coefficients (beta1, beta2) used for computing running averages.
Sourcepub fn with_weight_decay(self, weight_decay: f32) -> Result<Self, OptimError>
pub fn with_weight_decay(self, weight_decay: f32) -> Result<Self, OptimError>
Sets L2 weight decay factor in [0, +inf).
Sourcepub fn with_epsilon(self, epsilon: f32) -> Result<Self, OptimError>
pub fn with_epsilon(self, epsilon: f32) -> Result<Self, OptimError>
Sets epsilon value, must be finite and > 0.
Sourcepub fn clear_state(&mut self)
pub fn clear_state(&mut self)
Drops optimizer state (for example when restarting training).
Sourcepub fn learning_rate(&self) -> f32
pub fn learning_rate(&self) -> f32
Returns current learning rate.
Sourcepub fn set_learning_rate(&mut self, lr: f32) -> Result<(), OptimError>
pub fn set_learning_rate(&mut self, lr: f32) -> Result<(), OptimError>
Overrides current learning rate.
Sourcepub fn step(
&mut self,
parameter_id: u64,
weights: &mut Tensor,
grad: &Tensor,
) -> Result<(), OptimError>
pub fn step( &mut self, parameter_id: u64, weights: &mut Tensor, grad: &Tensor, ) -> Result<(), OptimError>
Applies one update to raw tensor weights.
Sourcepub fn step_graph_node(
&mut self,
graph: &mut Graph,
node: NodeId,
) -> Result<(), OptimError>
pub fn step_graph_node( &mut self, graph: &mut Graph, node: NodeId, ) -> Result<(), OptimError>
Applies one update to a trainable graph node by its NodeId.
Trait Implementations§
Source§impl LearningRate for Lamb
impl LearningRate for Lamb
Source§fn learning_rate(&self) -> f32
fn learning_rate(&self) -> f32
Returns current optimizer learning rate.
Source§fn set_learning_rate(&mut self, lr: f32) -> Result<(), OptimError>
fn set_learning_rate(&mut self, lr: f32) -> Result<(), OptimError>
Sets optimizer learning rate after validation.
Auto Trait Implementations§
impl Freeze for Lamb
impl RefUnwindSafe for Lamb
impl Send for Lamb
impl Sync for Lamb
impl Unpin for Lamb
impl UnsafeUnpin for Lamb
impl UnwindSafe for Lamb
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> 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