Skip to main content

core.Stat

core.Stat()

A statistic that merges under +, a monoid with the curvature’s init as identity.

Merging is associative: folding batches one by one and adding partial folds give the same statistic.

Attributes

Name Description
total_weight The summed weight of the examples folded in so far.

Methods

Name Description
add The statistic of both data sets together.
scaled The statistic with every summand multiplied by s.

add

core.Stat.__add__(other, /)

The statistic of both data sets together.

+ is how batches, partial folds and the shards of other processes combine, so it must be associative, with the curvature’s init as its identity.

Parameters

Name Type Description Default
other Self The statistic of other data, from the same curvature and parameters. required

Returns

Name Type Description
Self A statistic of the same type, as if one fold had seen both data sets.

scaled

core.Stat.scaled(s, /)

The statistic with every summand multiplied by s.

Meaningful only when the statistic is a sum (Requirements.additive_stat).

Parameters

Name Type Description Default
s Tensor A 0-dim factor. required

Returns

Name Type Description
Self A statistic of the same type.