pub struct DeterministicPhaseTrainer { /* private fields */ }Expand description
Deterministic phase-based trainer.
Orchestrates training with guaranteed deterministic outcomes. Uses warmup → full → predict → correct cycle with residual tracking.
Implementations§
Source§impl DeterministicPhaseTrainer
impl DeterministicPhaseTrainer
Sourcepub fn new(
param_shapes: &[(String, Vec<usize>)],
config: DeterministicPhaseConfig,
device: &Device,
) -> Result<DeterministicPhaseTrainer, OptimError>
pub fn new( param_shapes: &[(String, Vec<usize>)], config: DeterministicPhaseConfig, device: &Device, ) -> Result<DeterministicPhaseTrainer, OptimError>
Sourcepub fn begin_step(&mut self) -> Result<DeterministicStepInfo, OptimError>
pub fn begin_step(&mut self) -> Result<DeterministicStepInfo, OptimError>
Begin a training step.
Returns information about the current phase and whether backward pass (full gradient computation) is needed.
Sourcepub fn needs_backward(&self) -> bool
pub fn needs_backward(&self) -> bool
Check if backward pass is needed for current step.
Sourcepub fn record_full_gradients(
&mut self,
gradients: &HashMap<String, Tensor>,
) -> Result<(), OptimError>
pub fn record_full_gradients( &mut self, gradients: &HashMap<String, Tensor>, ) -> Result<(), OptimError>
Record full gradients after backward pass.
Called during WARMUP, FULL, or CORRECT phases after computing gradients via backpropagation.
§Arguments
gradients- Map of parameter names to gradient tensors
Sourcepub fn get_predicted_gradients(
&mut self,
) -> Result<HashMap<String, Tensor>, OptimError>
pub fn get_predicted_gradients( &mut self, ) -> Result<HashMap<String, Tensor>, OptimError>
Get predicted gradients for current step.
Called during PREDICT phase to get deterministic gradient predictions.
§Returns
Map of parameter names to predicted gradient tensors.
Sourcepub fn end_step(&mut self, loss: f32) -> Result<(), OptimError>
pub fn end_step(&mut self, loss: f32) -> Result<(), OptimError>
End the current training step.
Updates internal state and statistics.
§Arguments
loss- Loss value for this step
Sourcepub const fn current_phase(&self) -> DeterministicPhase
pub const fn current_phase(&self) -> DeterministicPhase
Get current training phase.
Sourcepub const fn warmup_complete(&self) -> bool
pub const fn warmup_complete(&self) -> bool
Check if warmup is complete.
Sourcepub fn get_stats(&self) -> DeterministicTrainerStats
pub fn get_stats(&self) -> DeterministicTrainerStats
Get training statistics.
Sourcepub fn reset(&mut self) -> Result<(), OptimError>
pub fn reset(&mut self) -> Result<(), OptimError>
Reset trainer state.
Auto Trait Implementations§
impl Freeze for DeterministicPhaseTrainer
impl !RefUnwindSafe for DeterministicPhaseTrainer
impl Send for DeterministicPhaseTrainer
impl Sync for DeterministicPhaseTrainer
impl Unpin for DeterministicPhaseTrainer
impl !UnwindSafe for DeterministicPhaseTrainer
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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