zero.metrics.Metric.calculate_iter

Metric.calculate_iter(iterable, star=False)[source]

Calculate metric for iterable.

The method does the following:

  1. resets the metric

  2. sequentially updates the metric with every value from iterable

  3. computes the result

  4. resets the metric

  5. returns the result

Parameters
  • iterable (Iterable) – data for Metric.update

  • star (bool) – if True, then update(*x) is performed instead of update(x)

Returns

The result of Metric.compute.

Return type

Any

Examples

metrics = metric_fn.calculate_iter(map(predict_batch, val_loader))