style: apply rustfmt across all crates and demos
Consistent formatting pass: line wrapping, import sorting, trailing whitespace removal, let-chain indentation, merged derive attributes, and unsafe block reformatting. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
@@ -107,19 +107,19 @@ impl CosineAnnealingScheduler {
|
||||
}
|
||||
|
||||
/// Get the minimum learning rate
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn min_lr(&self) -> f64 {
|
||||
self.min_lr
|
||||
}
|
||||
|
||||
/// Get the cycle length
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn t_max(&self) -> usize {
|
||||
self.t_max
|
||||
}
|
||||
|
||||
/// Check if using warm restarts
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn use_restarts(&self) -> bool {
|
||||
self.use_restarts
|
||||
}
|
||||
@@ -127,7 +127,7 @@ impl CosineAnnealingScheduler {
|
||||
/// Get the current cycle number (0-indexed)
|
||||
///
|
||||
/// Each cycle contains `t_max` + 1 steps (from 0 to `t_max` inclusive).
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn current_cycle(&self, step: usize) -> usize {
|
||||
if self.use_restarts {
|
||||
step / (self.t_max + 1)
|
||||
@@ -142,7 +142,7 @@ impl CosineAnnealingScheduler {
|
||||
/// - Steps 0 to `t_max` form one complete cycle (`t_max` + 1 total steps)
|
||||
/// - At step `t_max`, LR reaches `min_lr`
|
||||
/// - At step `t_max` + 1, a new cycle begins at `base_lr`
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn cycle_step(&self, step: usize) -> usize {
|
||||
if self.use_restarts {
|
||||
// Use t_max + 1 as period so step t_max is end of cycle (min_lr)
|
||||
@@ -154,7 +154,7 @@ impl CosineAnnealingScheduler {
|
||||
}
|
||||
|
||||
/// Get the progress within the current cycle (0.0 to 1.0)
|
||||
#[must_use]
|
||||
#[must_use]
|
||||
pub fn cycle_progress(&self, step: usize) -> f64 {
|
||||
let cycle_step = self.cycle_step(step);
|
||||
cycle_step as f64 / self.t_max as f64
|
||||
|
||||
Reference in New Issue
Block a user