Skip to main content

TrainingCallbackContext

Struct TrainingCallbackContext 

Source
pub struct TrainingCallbackContext<'a> { /* private fields */ }
Expand description

Restricted mutable services available to one callback invocation.

Implementations§

Source§

impl TrainingCallbackContext<'_>

Source

pub const fn snapshot(&self) -> TrainingSnapshot

Return the immutable state at this lifecycle boundary.

Source

pub fn optimizer(&mut self) -> &mut dyn Optimizer

Borrow the training optimizer for scheduling or checkpoint policy.

Source

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.

Source

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.

Source

pub fn committed_metrics(&self) -> &[CommittedMetric]

Return every metric committed so far, in commit order.

Source

pub fn latest_committed(&self, split: &str, name: &str) -> Option<f64>

Return the most recent committed value for split/name, when present.

Source

pub const fn config(&self) -> &TrainingConfig

Return the immutable iterator configuration.

Source

pub fn exclude_wall_time(&mut self, duration: Duration)

Exclude callback-owned work such as validation from throughput timing.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.