pub struct MixedPrecisionTrainer { /* private fields */ }Expand description
Mixed precision training manager.
Implementations§
Source§impl MixedPrecisionTrainer
impl MixedPrecisionTrainer
Sourcepub fn new(mode: PrecisionMode, scaler: LossScaler) -> Self
pub fn new(mode: PrecisionMode, scaler: LossScaler) -> Self
Creates a new mixed precision trainer.
Sourcepub fn register_weights(&mut self, name: String, weights: Array2<f32>)
pub fn register_weights(&mut self, name: String, weights: Array2<f32>)
Registers weights to maintain master copy.
Sourcepub fn cast_to_working_precision(&self, weights: &Array2<f32>) -> Array2<f32>
pub fn cast_to_working_precision(&self, weights: &Array2<f32>) -> Array2<f32>
Converts FP32 weights to working precision.
Sourcepub fn scale_loss(&mut self, loss: f32) -> f32
pub fn scale_loss(&mut self, loss: f32) -> f32
Scales loss for backward pass.
Sourcepub fn unscale_and_check_gradients(
&mut self,
gradients: &mut HashMap<String, Array2<f32>>,
) -> TrainResult<(bool, bool)>
pub fn unscale_and_check_gradients( &mut self, gradients: &mut HashMap<String, Array2<f32>>, ) -> TrainResult<(bool, bool)>
Sourcepub fn update_master_weights(&mut self, updates: &HashMap<String, Array2<f32>>)
pub fn update_master_weights(&mut self, updates: &HashMap<String, Array2<f32>>)
Updates master weights from working precision weights.
Sourcepub fn mode(&self) -> PrecisionMode
pub fn mode(&self) -> PrecisionMode
Gets the current precision mode.
Sourcepub fn current_scale(&self) -> f32
pub fn current_scale(&self) -> f32
Gets the current loss scale.
Sourcepub fn stats(&self) -> &MixedPrecisionStats
pub fn stats(&self) -> &MixedPrecisionStats
Gets training statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Resets statistics.
Auto Trait Implementations§
impl Freeze for MixedPrecisionTrainer
impl RefUnwindSafe for MixedPrecisionTrainer
impl Send for MixedPrecisionTrainer
impl Sync for MixedPrecisionTrainer
impl Unpin for MixedPrecisionTrainer
impl UnwindSafe for MixedPrecisionTrainer
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> 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