Skip to main content

PhaseCallback

Struct PhaseCallback 

Source
pub struct PhaseCallback<'hook> { /* private fields */ }
Expand description

Consecutive phase policy over one super::super::Training lifecycle.

The phase schedule does not own another iterator. Its epoch/step totals must exactly match the iterator configuration, and its optional transition hook receives restricted mutable access to the iterator’s existing optimizer.

Implementations§

Source§

impl<'hook> PhaseCallback<'hook>

Source

pub const fn new() -> Self

Construct an empty phase schedule.

Source

pub fn add_phase( &mut self, id: impl Into<String>, epochs: u64, steps: u64, ) -> Result<()>

Append a consecutive phase.

§Errors

Returns an error for invalid phase fields or aggregate count overflow.

Source

pub fn set_on_phase_begin( &mut self, hook: impl FnMut(usize, &TrainingPhase, &mut dyn Optimizer) -> Result<()> + 'hook, )

Install the hook invoked exactly once when each phase begins.

Source

pub fn phases(&self) -> &[TrainingPhase]

Return all configured phases in execution order.

Source

pub const fn current_phase(&self) -> Option<usize>

Return the currently entered phase index.

Source

pub fn total_epochs(&self) -> u64

Return the aggregate epoch count.

Source

pub fn total_steps(&self) -> u64

Return the aggregate step count.

Source

pub fn phase_for_epoch(&self, epoch: u64) -> Result<(usize, u64)>

Resolve a one-based global epoch to its phase index and one-based local epoch.

This query does not enter a phase or invoke its hook. Workloads that retain their own checkpoint boundaries can resolve restored progress without restarting callback accounting.

§Errors

Returns an error for zero or an epoch outside the configured schedule.

Trait Implementations§

Source§

impl Default for PhaseCallback<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl TrainingCallback for PhaseCallback<'_>

Source§

fn on_train_begin( &mut self, context: &mut TrainingCallbackContext<'_>, ) -> Result<TrainingControl>

Source§

fn on_epoch_begin( &mut self, context: &mut TrainingCallbackContext<'_>, ) -> Result<TrainingControl>

Source§

fn on_step_end( &mut self, _context: &mut TrainingCallbackContext<'_>, ) -> Result<TrainingControl>

Source§

fn on_epoch_end( &mut self, _context: &mut TrainingCallbackContext<'_>, ) -> Result<TrainingControl>

Source§

fn on_train_end( &mut self, _context: &mut TrainingCallbackContext<'_>, ) -> Result<TrainingControl>

Auto Trait Implementations§

§

impl<'hook> !RefUnwindSafe for PhaseCallback<'hook>

§

impl<'hook> !Send for PhaseCallback<'hook>

§

impl<'hook> !Sync for PhaseCallback<'hook>

§

impl<'hook> !UnwindSafe for PhaseCallback<'hook>

§

impl<'hook> Forget for PhaseCallback<'hook>

§

impl<'hook> Freeze for PhaseCallback<'hook>
where *const u8 is !null: Freeze, PhantomData<TrainingPhase>: Freeze, *const dyn FnMut(usize, &TrainingPhase, &mut dyn Optimizer) -> Result<(), Error> + 'hook is !null: Freeze, PhantomData<dyn FnMut(usize, &TrainingPhase, &mut dyn Optimizer) -> Result<(), Error> + 'hook>: Freeze,

§

impl<'hook> Move for PhaseCallback<'hook>

§

impl<'hook> Unpin for PhaseCallback<'hook>
where *const u8 is !null: Unpin, Box<dyn FnMut(usize, &TrainingPhase, &mut dyn Optimizer) -> Result<(), Error> + 'hook>: Unpin,

§

impl<'hook> UnsafeUnpin for PhaseCallback<'hook>

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.