pub struct LambConfig { /* private fields */ }Expand description
Lamb configuration.
Implementations§
Source§impl LambConfig
impl LambConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new instance of the config.
§Arguments
§Optional Arguments
§grad_clipping
Optional gradient clipping configuration.
- Defaults to
None
§Default Arguments
§beta_1
Exponential decay rate for the first moment estimates.
- Defaults to
0.9
§beta_2
Exponential decay rate for the second moment estimates.
- Defaults to
0.999
§epsilon
A value added to the denominator for numerical stability.
- Defaults to
1e-6
§weight_decay
Weight decay applied to the Adam update before layer-wise adaptation.
- Defaults to
0.0
§use_trust_ratio
Whether to scale each parameter update by its layer-wise trust ratio.
- Defaults to
true
Source§impl LambConfig
impl LambConfig
Sourcepub fn with_beta_1(self, beta_1: f32) -> Self
pub fn with_beta_1(self, beta_1: f32) -> Self
Sets the value for the field beta_1.
Exponential decay rate for the first moment estimates.
- Defaults to
0.9
Sourcepub fn with_beta_2(self, beta_2: f32) -> Self
pub fn with_beta_2(self, beta_2: f32) -> Self
Sets the value for the field beta_2.
Exponential decay rate for the second moment estimates.
- Defaults to
0.999
Sourcepub fn with_epsilon(self, epsilon: f32) -> Self
pub fn with_epsilon(self, epsilon: f32) -> Self
Sets the value for the field epsilon.
A value added to the denominator for numerical stability.
- Defaults to
1e-6
Sourcepub fn with_weight_decay(self, weight_decay: f32) -> Self
pub fn with_weight_decay(self, weight_decay: f32) -> Self
Sets the value for the field weight_decay.
Weight decay applied to the Adam update before layer-wise adaptation.
- Defaults to
0.0
Sourcepub fn with_use_trust_ratio(self, use_trust_ratio: bool) -> Self
pub fn with_use_trust_ratio(self, use_trust_ratio: bool) -> Self
Sets the value for the field use_trust_ratio.
Whether to scale each parameter update by its layer-wise trust ratio.
- Defaults to
true
Sourcepub fn with_grad_clipping(
self,
grad_clipping: Option<GradientClippingConfig>,
) -> Self
pub fn with_grad_clipping( self, grad_clipping: Option<GradientClippingConfig>, ) -> Self
Sets the value for the field grad_clipping.
Optional gradient clipping configuration.
- Defaults to
None
Source§impl LambConfig
impl LambConfig
Sourcepub fn build(&self) -> Lamb
pub fn build(&self) -> Lamb
Build the per-parameter LAMB optimizer.
Use Self::init to construct a whole-module optimizer with the configured gradient
clipping behavior.
Sourcepub fn init(&self) -> ModuleOptimizer
pub fn init(&self) -> ModuleOptimizer
Initialize a whole-module LAMB optimizer.
Trait Implementations§
Source§impl Clone for LambConfig
impl Clone for LambConfig
Source§impl Config for LambConfig
impl Config for LambConfig
Source§fn save<P>(&self, file: P) -> Result<(), Error>
fn save<P>(&self, file: P) -> Result<(), Error>
std only.Source§fn load<P>(file: P) -> Result<Self, ConfigError>
fn load<P>(file: P) -> Result<Self, ConfigError>
std only.Source§fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
Source§impl Debug for LambConfig
impl Debug for LambConfig
Source§impl<'de> Deserialize<'de> for LambConfig
impl<'de> Deserialize<'de> for LambConfig
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>,
Source§impl Display for LambConfig
impl Display for LambConfig
Auto Trait Implementations§
impl Freeze for LambConfig
impl RefUnwindSafe for LambConfig
impl Send for LambConfig
impl Sync for LambConfig
impl Unpin for LambConfig
impl UnsafeUnpin for LambConfig
impl UnwindSafe for LambConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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> ⓘ
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