pub struct StepLrSchedulerConfig { /* private fields */ }
Available on crate feature
std
only.Expand description
The configuration for create a step learning rate scheduler.
This scheduler returns the learning rate initial_lr
from the start, and keeps doing so until
the same value has been given for step_size
times. Then it multiplies the learning rate by
gamma
before repeating the process.
Gamma values out of range (0.0, 1.0) and non-positive initial learning rates are acceptable, but a warning log will be output for such a value in case of mistyping.
§Notes
The step method of the scheduler panics if it is called more than
i32::MAX + 1
times.
Implementations§
Source§impl StepLrSchedulerConfig
impl StepLrSchedulerConfig
Sourcepub fn new(initial_lr: LearningRate, step_size: usize) -> Self
pub fn new(initial_lr: LearningRate, step_size: usize) -> Self
Create a new instance of the config.
Source§impl StepLrSchedulerConfig
impl StepLrSchedulerConfig
Sourcepub fn with_gamma(self, gamma: f64) -> Self
pub fn with_gamma(self, gamma: f64) -> Self
The factor by which the learning rate is multiplied with each update. Default: 0.1.
Source§impl StepLrSchedulerConfig
impl StepLrSchedulerConfig
Sourcepub fn init(&self) -> Result<StepLrScheduler, String>
pub fn init(&self) -> Result<StepLrScheduler, String>
Trait Implementations§
Source§impl Clone for StepLrSchedulerConfig
impl Clone for StepLrSchedulerConfig
Source§impl Config for StepLrSchedulerConfig
impl Config for StepLrSchedulerConfig
Source§fn save<P: AsRef<Path>>(&self, file: P) -> Result<()>
fn save<P: AsRef<Path>>(&self, file: P) -> Result<()>
Saves the configuration to a file. Read more
Source§fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
Loads the configuration from a file. Read more
Source§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<'de> Deserialize<'de> for StepLrSchedulerConfig
impl<'de> Deserialize<'de> for StepLrSchedulerConfig
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 StepLrSchedulerConfig
impl Display for StepLrSchedulerConfig
Auto Trait Implementations§
impl Freeze for StepLrSchedulerConfig
impl RefUnwindSafe for StepLrSchedulerConfig
impl Send for StepLrSchedulerConfig
impl Sync for StepLrSchedulerConfig
impl Unpin for StepLrSchedulerConfig
impl UnwindSafe for StepLrSchedulerConfig
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.