pub struct DeterministicPredictor { /* private fields */ }Expand description
Deterministic gradient predictor.
Maintains gradient history and fits a linear model to predict future gradients deterministically.
Implementations§
Source§impl DeterministicPredictor
impl DeterministicPredictor
Sourcepub fn new(
param_shapes: &[(String, Vec<usize>)],
config: DeterministicPredictionConfig,
device: &Device,
) -> Result<DeterministicPredictor, OptimError>
pub fn new( param_shapes: &[(String, Vec<usize>)], config: DeterministicPredictionConfig, device: &Device, ) -> Result<DeterministicPredictor, OptimError>
Create a new deterministic predictor.
§Arguments
param_shapes- List of (name, shape) tuples for parametersconfig- Prediction configurationdevice- Device for tensor storage
Sourcepub fn needs_correction(&self) -> bool
pub fn needs_correction(&self) -> bool
Check if correction is needed based on residual magnitude.
Sourcepub fn record_gradient(
&mut self,
gradients: &HashMap<String, Tensor>,
is_correction: bool,
) -> Result<(), OptimError>
pub fn record_gradient( &mut self, gradients: &HashMap<String, Tensor>, is_correction: bool, ) -> Result<(), OptimError>
Record a gradient from full computation.
Updates history and potentially refits the prediction model.
§Arguments
gradients- Map of parameter names to gradient tensorsis_correction- Whether this is a correction step (vs. regular full step)
Sourcepub fn predict_gradient(
&mut self,
) -> Result<HashMap<String, Tensor>, OptimError>
pub fn predict_gradient( &mut self, ) -> Result<HashMap<String, Tensor>, OptimError>
Predict gradient for current step.
Uses the fitted linear model to extrapolate from history. Prediction is fully deterministic.
§Returns
Map of parameter names to predicted gradient tensors.
Sourcepub fn get_stats(&self) -> &PredictorStatistics
pub fn get_stats(&self) -> &PredictorStatistics
Get prediction statistics.
Sourcepub fn reset(&mut self) -> Result<(), OptimError>
pub fn reset(&mut self) -> Result<(), OptimError>
Reset predictor state.
Sourcepub const fn global_step(&self) -> usize
pub const fn global_step(&self) -> usize
Get current global step.
Auto Trait Implementations§
impl Freeze for DeterministicPredictor
impl !RefUnwindSafe for DeterministicPredictor
impl Send for DeterministicPredictor
impl Sync for DeterministicPredictor
impl Unpin for DeterministicPredictor
impl !UnwindSafe for DeterministicPredictor
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> 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>
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