Realm

oa::ml::metric::TopKAccuracy

Additive top-k correct/sample counters. A sample is correct when its label’s logit is at least the k-th largest logit in its row — the inclusive boundary convention, so ties at the threshold count as correct and k ≥ classes is trivially perfect. Like the confusion counts, observation happens at the evaluation plane: logits and labels cross the host boundary once per evaluation batch and the ranking derivation runs host-side. The mergeable state is the same additive correct/samples pair categorical accuracy uses, so partitioned evaluation merges exactly.

StRust public API

Declaration

pub struct TopKAccuracy { /* private fields */ }
Public Rust declaration.

Public Methods

pub const fn k(&self) -> usize
pub fn update_device(&mut self, logits: &Matrix, labels: &Matrix) -> Result<()>
pub fn merge(&mut self, other: &mut Self) -> Result<()>
pub fn result(&mut self) -> Result<f64>
pub const fn samples(&self) -> u64
pub fn reset(&mut self)

Associated Functions

pub fn new(k: usize) -> Self

Public Method Documentation

pub const fn k( &self ) -> usize
No public source comment is attached to this declaration.
pub fn update_device(&mut self, logits: &Matrix, labels: &Matrix) -> Result<()>
No public source comment is attached to this declaration.
pub fn merge(&mut self, other: &mut Self) -> Result<()>
No public source comment is attached to this declaration.
pub fn result( &mut self ) -> Result<f64>
No public source comment is attached to this declaration.
pub const fn samples( &self ) -> u64
No public source comment is attached to this declaration.
pub fn reset( &mut self )
No public source comment is attached to this declaration.
pub fn new( k: usize ) -> Self
No public source comment is attached to this declaration.