pub struct TrainingCallbackContext<'a> { /* private fields */ }Expand description
Restricted mutable services available to one callback invocation.
Implementations§
Source§impl TrainingCallbackContext<'_>
impl TrainingCallbackContext<'_>
Sourcepub const fn snapshot(&self) -> TrainingSnapshot
pub const fn snapshot(&self) -> TrainingSnapshot
Return the immutable state at this lifecycle boundary.
Sourcepub fn optimizer(&mut self) -> &mut dyn Optimizer
pub fn optimizer(&mut self) -> &mut dyn Optimizer
Borrow the training optimizer for scheduling or checkpoint policy.
Sourcepub fn checkpoint_optimizer(&mut self) -> Result<&mut dyn CheckpointOptimizer>
pub fn checkpoint_optimizer(&mut self) -> Result<&mut dyn CheckpointOptimizer>
Borrow native checkpoint persistence when the optimizer admits it.
§Errors
Returns an error when the iterator was constructed through the open eager-only optimizer route.
Sourcepub fn commit_metric(&mut self, split: &str, name: &str, value: f64)
pub fn commit_metric(&mut self, split: &str, name: &str, value: f64)
Commit one metric value to the shared training history.
Entries order by commit time at this lifecycle boundary: training metrics the lifecycle itself commits come first, then values committed by callbacks in registration order. Later callbacks and every sink read the committed value rather than re-deriving it.
Sourcepub fn committed_metrics(&self) -> &[CommittedMetric]
pub fn committed_metrics(&self) -> &[CommittedMetric]
Return every metric committed so far, in commit order.
Sourcepub fn latest_committed(&self, split: &str, name: &str) -> Option<f64>
pub fn latest_committed(&self, split: &str, name: &str) -> Option<f64>
Return the most recent committed value for split/name, when present.
Sourcepub const fn config(&self) -> &TrainingConfig
pub const fn config(&self) -> &TrainingConfig
Return the immutable iterator configuration.
Sourcepub fn exclude_wall_time(&mut self, duration: Duration)
pub fn exclude_wall_time(&mut self, duration: Duration)
Exclude callback-owned work such as validation from throughput timing.