pub struct MixedPrecisionState {
pub config: MixedPrecisionConfig,
pub scaler: LossScaler,
pub master_weights: HashMap<String, Vec<f64>>,
pub successful_steps: usize,
pub skipped_steps: usize,
pub step: usize,
}Expand description
Mixed precision training state.
Fields§
§config: MixedPrecisionConfigConfiguration
scaler: LossScalerLoss scaler
master_weights: HashMap<String, Vec<f64>>Master weights (FP32 copies of parameters)
successful_steps: usizeNumber of successful steps
skipped_steps: usizeNumber of skipped steps due to overflow
step: usizeTraining step counter
Implementations§
Source§impl MixedPrecisionState
impl MixedPrecisionState
Sourcepub fn new(config: MixedPrecisionConfig) -> Result<Self, MixedPrecisionError>
pub fn new(config: MixedPrecisionConfig) -> Result<Self, MixedPrecisionError>
Create a new mixed precision training state.
Sourcepub fn init_master_weights(&mut self, params: &HashMap<String, Vec<f64>>)
pub fn init_master_weights(&mut self, params: &HashMap<String, Vec<f64>>)
Initialize master weights.
Sourcepub fn current_loss_scale(&self) -> f64
pub fn current_loss_scale(&self) -> f64
Get current loss scale.
Sourcepub fn stats(&self) -> MixedPrecisionStats
pub fn stats(&self) -> MixedPrecisionStats
Get training statistics.
Sourcepub fn process_step(
&mut self,
loss: f64,
gradients: &mut HashMap<String, f64>,
) -> Result<bool, MixedPrecisionError>
pub fn process_step( &mut self, loss: f64, gradients: &mut HashMap<String, f64>, ) -> Result<bool, MixedPrecisionError>
Process training step with automatic loss scaling.
Trait Implementations§
Source§impl Clone for MixedPrecisionState
impl Clone for MixedPrecisionState
Source§fn clone(&self) -> MixedPrecisionState
fn clone(&self) -> MixedPrecisionState
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 MixedPrecisionState
impl RefUnwindSafe for MixedPrecisionState
impl Send for MixedPrecisionState
impl Sync for MixedPrecisionState
impl Unpin for MixedPrecisionState
impl UnwindSafe for MixedPrecisionState
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