pub struct ParameterUpdate;Expand description
Common parameter update operations.
Implementations§
Source§impl ParameterUpdate
impl ParameterUpdate
Sourcepub fn apply_l2_regularization(grad: f32, param: f32, weight_decay: f32) -> f32
pub fn apply_l2_regularization(grad: f32, param: f32, weight_decay: f32) -> f32
Applies weight decay to gradients (L2 regularization).
§Arguments
grad- The gradient valueparam- The parameter valueweight_decay- The weight decay coefficient
Sourcepub fn apply_decoupled_weight_decay(param: &mut f32, lr: f32, weight_decay: f32)
pub fn apply_decoupled_weight_decay(param: &mut f32, lr: f32, weight_decay: f32)
Applies decoupled weight decay directly to parameter.
§Arguments
param- The parameter value to updatelr- The learning rateweight_decay- The weight decay coefficient
Sourcepub fn adam_update(param: &mut f32, lr: f32, m_hat: f32, v_hat: f32, eps: f32)
pub fn adam_update(param: &mut f32, lr: f32, m_hat: f32, v_hat: f32, eps: f32)
Updates parameter using Adam-style formula.
§Arguments
param- The parameter to updatelr- Learning ratem_hat- Bias-corrected first momentv_hat- Bias-corrected second momenteps- Epsilon for numerical stability
Sourcepub fn sgd_momentum_update(param: &mut f32, lr: f32, momentum: f32)
pub fn sgd_momentum_update(param: &mut f32, lr: f32, momentum: f32)
Updates parameter using SGD with momentum.
§Arguments
param- The parameter to updatelr- Learning ratemomentum- Momentum buffer value
Sourcepub fn update_sgd_momentum(
momentum: &mut f32,
grad: f32,
momentum_coeff: f32,
dampening: f32,
nesterov: bool,
) -> f32
pub fn update_sgd_momentum( momentum: &mut f32, grad: f32, momentum_coeff: f32, dampening: f32, nesterov: bool, ) -> f32
Updates momentum buffer for SGD.
§Arguments
momentum- The momentum buffer to updategrad- The gradientmomentum_coeff- Momentum coefficient (typically 0.9)dampening- Dampening factor (typically 0.0)nesterov- Whether to use Nesterov momentum
Auto Trait Implementations§
impl Freeze for ParameterUpdate
impl RefUnwindSafe for ParameterUpdate
impl Send for ParameterUpdate
impl Sync for ParameterUpdate
impl Unpin for ParameterUpdate
impl UnwindSafe for ParameterUpdate
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> 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 more