Realm

oa::ml::TrainingMetric

Stateful metric updated once after each completed step. Snapshot-only loss-style metrics implement the four legacy methods. Prediction metrics need batch tensors the snapshot does not carry: they instead observe batches inside the step’s record closure (AccuracyObserver::observe) and commit their epoch result to the shared history bus through TrainingMetric::commit_epoch. New code should not add snapshot-only metrics; the snapshot path exists for scalars the lifecycle itself produces.

TrRust public API

Declaration

pub trait TrainingMetric { // Required methods fn name(&self) -> &str; fn reset(&mut self); fn update_step(&mut self, state: TrainingSnapshot); fn result(&self) -> f64; // Provided methods fn commit_epoch( &mut self, _context: &mut TrainingCallbackContext<'_>, ) -> Result<()> { ... } fn observe_batch( &mut self, _prediction: &Matrix, _target: &Matrix, ) -> Result<()> { ... } }
Public Rust declaration.

Public Methods

fn name(&self) -> &str
fn reset(&mut self)
fn update_step(&mut self, state: TrainingSnapshot)
fn result(&self) -> f64
fn commit_epoch( &mut self, _context: &mut TrainingCallbackContext<'_>, ) -> Result<()>
fn observe_batch( &mut self, _prediction: &Matrix, _target: &Matrix, ) -> Result<()>

Public Method Documentation

fn name( &self ) -> &str
No public source comment is attached to this declaration.
fn reset( &mut self )
No public source comment is attached to this declaration.
fn update_step( &mut self, state: TrainingSnapshot )
No public source comment is attached to this declaration.
fn result( &self ) -> f64
No public source comment is attached to this declaration.
fn commit_epoch( &mut self, _context: &mut TrainingCallbackContext<'_>, ) -> Result<()>
No public source comment is attached to this declaration.
fn observe_batch( &mut self, _prediction: &Matrix, _target: &Matrix, ) -> Result<()>
No public source comment is attached to this declaration.