pub struct DynamicLossScaler { /* private fields */ }Expand description
State for dynamic loss scaling during mixed-precision training.
Implementations§
Source§impl DynamicLossScaler
impl DynamicLossScaler
pub fn new(initial_scale: f32) -> Self
pub fn scale(&self) -> f32
Sourcepub fn scale_loss(&self, loss: &Tensor) -> Result<Tensor, ModelError>
pub fn scale_loss(&self, loss: &Tensor) -> Result<Tensor, ModelError>
Scale a loss tensor by the current loss scale factor.
Sourcepub fn unscale_gradients(&self, gradients: &[Tensor]) -> Vec<Tensor>
pub fn unscale_gradients(&self, gradients: &[Tensor]) -> Vec<Tensor>
Unscale gradients by dividing by the current scale factor.
Sourcepub fn check_overflow(gradients: &[Tensor]) -> bool
pub fn check_overflow(gradients: &[Tensor]) -> bool
Check if any gradient contains inf/nan (overflow indicator).
Trait Implementations§
Source§impl Clone for DynamicLossScaler
impl Clone for DynamicLossScaler
Source§fn clone(&self) -> DynamicLossScaler
fn clone(&self) -> DynamicLossScaler
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 moreAuto Trait Implementations§
impl Freeze for DynamicLossScaler
impl RefUnwindSafe for DynamicLossScaler
impl Send for DynamicLossScaler
impl Sync for DynamicLossScaler
impl Unpin for DynamicLossScaler
impl UnsafeUnpin for DynamicLossScaler
impl UnwindSafe for DynamicLossScaler
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