pub struct CosineAnnealingLr {
pub max_lr: f64,
pub min_lr: f64,
pub total_steps: usize,
pub warmup_steps: usize,
}Expand description
§Cosine Annealing Learning Rate Scheduler with Linear Warmup.
This scheduler:
- Linearly increases LR from 0 to
max_lrduring warmup phase - Applies cosine annealing from
max_lrtomin_lrafter warmup
This is a common pattern in modern deep learning training.
Fields§
§max_lr: f64The maximum learning rate (reached after warmup)
min_lr: f64The minimum learning rate (reached at end of training)
total_steps: usizeThe total number of training steps
warmup_steps: usizeThe number of warmup steps
Implementations§
Source§impl CosineAnnealingLr
impl CosineAnnealingLr
Sourcepub fn new(total_steps: usize) -> Self
pub fn new(total_steps: usize) -> Self
Create a new instance of the config.
§Arguments
§Required Arguments
§total_steps
The total number of training steps
§Default Arguments
§max_lr
The maximum learning rate (reached after warmup)
- Defaults to
1e-4
§min_lr
The minimum learning rate (reached at end of training)
- Defaults to
1e-6
§warmup_steps
The number of warmup steps
- Defaults to
0
Source§impl CosineAnnealingLr
impl CosineAnnealingLr
Sourcepub fn with_max_lr(self, max_lr: f64) -> Self
pub fn with_max_lr(self, max_lr: f64) -> Self
Sets the value for the field max_lr.
The maximum learning rate (reached after warmup)
- Defaults to
1e-4
Sourcepub fn with_min_lr(self, min_lr: f64) -> Self
pub fn with_min_lr(self, min_lr: f64) -> Self
Sets the value for the field min_lr.
The minimum learning rate (reached at end of training)
- Defaults to
1e-6
Sourcepub fn with_warmup_steps(self, warmup_steps: usize) -> Self
pub fn with_warmup_steps(self, warmup_steps: usize) -> Self
Trait Implementations§
Source§impl Clone for CosineAnnealingLr
impl Clone for CosineAnnealingLr
Source§impl Config for CosineAnnealingLr
impl Config for CosineAnnealingLr
§fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
Loads the configuration from a binary buffer. Read more
Source§impl Debug for CosineAnnealingLr
impl Debug for CosineAnnealingLr
Source§impl<'de> Deserialize<'de> for CosineAnnealingLr
impl<'de> Deserialize<'de> for CosineAnnealingLr
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for CosineAnnealingLr
impl Display for CosineAnnealingLr
Auto Trait Implementations§
impl Freeze for CosineAnnealingLr
impl RefUnwindSafe for CosineAnnealingLr
impl Send for CosineAnnealingLr
impl Sync for CosineAnnealingLr
impl Unpin for CosineAnnealingLr
impl UnsafeUnpin for CosineAnnealingLr
impl UnwindSafe for CosineAnnealingLr
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