Trait Metric

pub trait Metric: Send + Sync {
    type Input;

    // Required methods
    fn name(&self) -> String;
    fn update(
        &mut self,
        item: &Self::Input,
        metadata: &MetricMetadata,
    ) -> MetricEntry;
    fn clear(&mut self);
}
Expand description

Metric trait.

§Notes

Implementations should define their own input type only used by the metric. This is important since some conflict may happen when the model output is adapted for each metric’s input type.

Required Associated Types§

type Input

The input type of the metric.

Required Methods§

fn name(&self) -> String

The parameterized name of the metric.

This should be unique, so avoid using short generic names, prefer using the long name.

For a metric that can exist at different parameters (e.g., top-k accuracy for different values of k), the name should be unique for each instance.

fn update( &mut self, item: &Self::Input, metadata: &MetricMetadata, ) -> MetricEntry

Update the metric state and returns the current metric entry.

fn clear(&mut self)

Clear the metric state.

Implementors§

§

impl Metric for CpuMemory

§

type Input = ()

§

impl Metric for CpuTemperature

§

type Input = ()

§

impl Metric for CpuUse

§

type Input = ()

§

impl Metric for CudaMetric

§

type Input = ()

§

impl Metric for IterationSpeedMetric

§

type Input = ()

§

impl Metric for LearningRateMetric

§

type Input = ()

§

impl<B> Metric for AccuracyMetric<B>
where B: Backend,

§

impl<B> Metric for AurocMetric<B>
where B: Backend,

§

impl<B> Metric for FBetaScoreMetric<B>
where B: Backend,

§

impl<B> Metric for HammingScore<B>
where B: Backend,

§

impl<B> Metric for LossMetric<B>
where B: Backend,

§

type Input = LossInput<B>

§

impl<B> Metric for PrecisionMetric<B>
where B: Backend,

§

impl<B> Metric for RecallMetric<B>
where B: Backend,

§

impl<B> Metric for TopKAccuracyMetric<B>
where B: Backend,