pub struct OptimizerCheckpoint {
pub step: u64,
pub epoch: u32,
pub optimizer_name: String,
pub param_states: HashMap<String, ParamState>,
pub hyperparams: HashMap<String, f64>,
pub metadata: CheckpointMetadata,
}Expand description
Serialisable snapshot of an optimizer’s full training state.
Fields§
§step: u64§epoch: u32§optimizer_name: String§param_states: HashMap<String, ParamState>Parameter name → per-parameter state.
hyperparams: HashMap<String, f64>§metadata: CheckpointMetadataImplementations§
Source§impl OptimizerCheckpoint
impl OptimizerCheckpoint
Sourcepub fn new(optimizer_name: impl Into<String>, step: u64, epoch: u32) -> Self
pub fn new(optimizer_name: impl Into<String>, step: u64, epoch: u32) -> Self
Create an empty checkpoint for the given optimizer at step/epoch.
Sourcepub fn add_param_state(&mut self, name: impl Into<String>, state: ParamState)
pub fn add_param_state(&mut self, name: impl Into<String>, state: ParamState)
Insert or replace the state for one parameter.
Sourcepub fn set_hyperparam(&mut self, key: impl Into<String>, value: f64)
pub fn set_hyperparam(&mut self, key: impl Into<String>, value: f64)
Record a scalar hyper-parameter (learning rate, beta1, etc.).
Sourcepub fn get_hyperparam(&self, key: &str) -> Option<f64>
pub fn get_hyperparam(&self, key: &str) -> Option<f64>
Retrieve a previously recorded hyper-parameter value.
Sourcepub fn num_params(&self) -> usize
pub fn num_params(&self) -> usize
Number of parameters stored in this checkpoint.
Sourcepub fn total_elements(&self) -> usize
pub fn total_elements(&self) -> usize
Total number of scalar elements across all first-moment vectors.
Trait Implementations§
Source§impl Clone for OptimizerCheckpoint
impl Clone for OptimizerCheckpoint
Source§fn clone(&self) -> OptimizerCheckpoint
fn clone(&self) -> OptimizerCheckpoint
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 OptimizerCheckpoint
impl Debug for OptimizerCheckpoint
Source§impl<'de> Deserialize<'de> for OptimizerCheckpoint
impl<'de> Deserialize<'de> for OptimizerCheckpoint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for OptimizerCheckpoint
impl RefUnwindSafe for OptimizerCheckpoint
impl Send for OptimizerCheckpoint
impl Sync for OptimizerCheckpoint
impl Unpin for OptimizerCheckpoint
impl UnsafeUnpin for OptimizerCheckpoint
impl UnwindSafe for OptimizerCheckpoint
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