pub struct AccumulationConfig {
pub accumulation_steps: usize,
pub normalize: bool,
pub max_grad_norm: Option<f64>,
}Expand description
Configuration for gradient accumulation.
Fields§
§accumulation_steps: usizeNumber of micro-batches to accumulate before triggering an update.
normalize: boolWhether to normalize (average) gradients across micro-batches.
max_grad_norm: Option<f64>Maximum gradient norm for clipping (None = no clipping).
Implementations§
Source§impl AccumulationConfig
impl AccumulationConfig
Sourcepub fn new(steps: usize) -> Self
pub fn new(steps: usize) -> Self
Create a new config with the given number of accumulation steps. Clamps to a minimum of 1.
Sourcepub fn with_normalize(self, normalize: bool) -> Self
pub fn with_normalize(self, normalize: bool) -> Self
Set whether to normalize (average) gradients.
Sourcepub fn with_max_grad_norm(self, norm: f64) -> Self
pub fn with_max_grad_norm(self, norm: f64) -> Self
Set maximum gradient norm for clipping.
Sourcepub fn effective_batch_size(&self, micro_batch_size: usize) -> usize
pub fn effective_batch_size(&self, micro_batch_size: usize) -> usize
Compute the effective batch size given the micro-batch size.
Trait Implementations§
Source§impl Clone for AccumulationConfig
impl Clone for AccumulationConfig
Source§fn clone(&self) -> AccumulationConfig
fn clone(&self) -> AccumulationConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AccumulationConfig
impl Debug for AccumulationConfig
Auto Trait Implementations§
impl Freeze for AccumulationConfig
impl RefUnwindSafe for AccumulationConfig
impl Send for AccumulationConfig
impl Sync for AccumulationConfig
impl Unpin for AccumulationConfig
impl UnsafeUnpin for AccumulationConfig
impl UnwindSafe for AccumulationConfig
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> 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