pub struct CustomScheduler<A, F>{ /* private fields */ }Expand description
A custom scheduler that uses a closure to compute the learning rate
Implementations§
Source§impl<A, F> CustomScheduler<A, F>
impl<A, F> CustomScheduler<A, F>
Sourcepub fn new(_initial_lr: A, lrfunc: F) -> CustomScheduler<A, F>
pub fn new(_initial_lr: A, lrfunc: F) -> CustomScheduler<A, F>
Create a new custom scheduler with the given initial learning rate and computation function
§Arguments
initial_lr- The initial learning rate (used only for documentation)lr_func- A function that takes the current step count and returns the learning rate
§Example
use optirs_core::schedulers::{CustomScheduler, LearningRateScheduler};
// Create a scheduler that reduces the learning rate by 10% every 10 steps
let mut scheduler = CustomScheduler::new(0.1, |step| {
0.1 * 0.9_f64.powi((step / 10) as i32)
});
assert_eq!(scheduler.get_learning_rate(), 0.1);
scheduler.step();Sourcepub fn get_step_count(&self) -> usize
pub fn get_step_count(&self) -> usize
Get the current step count
Trait Implementations§
Source§impl<A, F> LearningRateScheduler<A> for CustomScheduler<A, F>
impl<A, F> LearningRateScheduler<A> for CustomScheduler<A, F>
Source§fn get_learning_rate(&self) -> A
fn get_learning_rate(&self) -> A
Get the learning rate at the current step
Source§fn step_with_metric(&mut self, metric: A) -> A
fn step_with_metric(&mut self, metric: A) -> A
Update the scheduler state using an observed metric and return the new learning rate Read more
Auto Trait Implementations§
impl<A, F> !RefUnwindSafe for CustomScheduler<A, F>
impl<A, F> !Send for CustomScheduler<A, F>
impl<A, F> !Sync for CustomScheduler<A, F>
impl<A, F> !UnwindSafe for CustomScheduler<A, F>
impl<A, F> Freeze for CustomScheduler<A, F>
impl<A, F> Unpin for CustomScheduler<A, F>where
A: Unpin,
impl<A, F> UnsafeUnpin for CustomScheduler<A, F>
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.