Monitor

class tinder.monitor.Stat(alpha: float = 0.6)[source]

A small class that calculates the statistics for a scalar metric. This is useful to calcaulate accuracies and losses across minibatches.

Parameters

alpha (float) – Defaults to 1. Weight(0~1) used for exponential moving average. A smaller weight reprsents more smooth average.

count

the number of samples.

Type

int

sum
Type

float

average

the average of samples. read-only.

Type

float

ema

exponential moving average.

Type

float

alpha

coefficient for exponential moving average.

Type

float

average

Average of all samples.

Returns

average

clear()[source]

Clear the history and reset stats to zero.

update(value, count: int = 1, is_mean=False)[source]

Update stats with new samples.

Parameters
  • value (int or float) – new sample, or average of multiple samples.

  • count (int) – Defaults to 1. This is useful when batch size is not uniform.

class tinder.monitor.Stats(**stats)[source]

A class that holds named stats.

clear()[source]

Clear all stats.