pub struct EVA { /* private fields */ }Expand description
EVA (Exponential Moving Average with Variance Adaptation) optimizer.
Implementations§
Source§impl EVA
impl EVA
Sourcepub fn new(
lr: f32,
beta1: f32,
beta2: f32,
eps: f32,
weight_decay: f32,
variance_adaptation: bool,
) -> Self
pub fn new( lr: f32, beta1: f32, beta2: f32, eps: f32, weight_decay: f32, variance_adaptation: bool, ) -> Self
Creates a new EVA optimizer with default configuration.
Sourcepub fn with_config(config: EVAConfig) -> Self
pub fn with_config(config: EVAConfig) -> Self
Creates a new EVA optimizer with custom configuration.
Sourcepub fn adamw_like(lr: f32, weight_decay: f32) -> Self
pub fn adamw_like(lr: f32, weight_decay: f32) -> Self
Convenience constructor for EVA with AdamW-like settings.
Sourcepub fn no_variance_adaptation(lr: f32, beta1: f32, beta2: f32, eps: f32) -> Self
pub fn no_variance_adaptation(lr: f32, beta1: f32, beta2: f32, eps: f32) -> Self
Convenience constructor for EVA with variance adaptation disabled.
Sourcepub fn memory_stats(&self) -> StateMemoryStats
pub fn memory_stats(&self) -> StateMemoryStats
Gets memory statistics for the optimizer state.
Trait Implementations§
Source§impl Optimizer for EVA
impl Optimizer for EVA
Source§fn update(&mut self, parameter: &mut Tensor, grad: &Tensor) -> Result<()>
fn update(&mut self, parameter: &mut Tensor, grad: &Tensor) -> Result<()>
Updates a parameter based on its gradient. Read more
Source§fn accumulate_grad(
&mut self,
parameter: &mut Tensor,
grad: &Tensor,
) -> Result<(), TrustformersError>
fn accumulate_grad( &mut self, parameter: &mut Tensor, grad: &Tensor, ) -> Result<(), TrustformersError>
Accumulates gradients for gradient accumulation. Read more
Source§fn apply_accumulated_grads(
&mut self,
accumulation_steps: usize,
) -> Result<(), TrustformersError>
fn apply_accumulated_grads( &mut self, accumulation_steps: usize, ) -> Result<(), TrustformersError>
Applies accumulated gradients after gradient accumulation. Read more
Source§impl StatefulOptimizer for EVA
impl StatefulOptimizer for EVA
Source§type State = OptimizerState
type State = OptimizerState
The state type used by this optimizer.
Source§fn state(&self) -> &OptimizerState
fn state(&self) -> &OptimizerState
Gets a reference to the optimizer’s internal state.
Source§fn state_mut(&mut self) -> &mut OptimizerState
fn state_mut(&mut self) -> &mut OptimizerState
Gets a mutable reference to the optimizer’s internal state.
Source§fn memory_usage(&self) -> StateMemoryStats
fn memory_usage(&self) -> StateMemoryStats
Gets memory usage statistics for this optimizer.
Source§fn reset_state(&mut self)
fn reset_state(&mut self)
Resets the optimizer state (useful for training restarts).
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Returns the number of parameters being optimized.
Auto Trait Implementations§
impl Freeze for EVA
impl RefUnwindSafe for EVA
impl Send for EVA
impl Sync for EVA
impl Unpin for EVA
impl UnwindSafe for EVA
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