1 utils.metric_reductions

utils.metric_reductions

Shared finalization of additive metric totals and observation counts.

Metric owners choose which observations contribute to each state. After local or distributed accumulation, this operation computes their mean without turning an unobserved population into a measured zero.

1.1 Functions

Name Description
mean_from_sum_count Divide accumulated totals by counts, yielding NaN for nonpositive counts.

1.1.1 mean_from_sum_count

utils.metric_reductions.mean_from_sum_count(total, count)

Divide accumulated totals by counts, yielding NaN for nonpositive counts.

1.1.1.1 Parameters

Name Type Description Default
total Tensor["...", float32|float64] Accumulated metric sums. required
count Tensor["...", float32|float64] Observation counts on the same device, broadcast-compatible with total. Counts are normally nonnegative integers stored in floating-point metric state. required

1.1.1.2 Returns

Name Type Description
Tensor Tensor["...", float32\|float64]: Broadcast result, retaining PyTorch
Tensor dtype promotion and autograd. Positive denominators retain the existing
Tensor clamp to at least one; nonpositive counts produce NaN. Nonfinite totals
Tensor propagate for positive counts. Neither input is mutated.
Back to top