DefaultMetricFormatter

class tfsnippet.DefaultMetricFormatter

Bases: tfsnippet.scaffold.logs.MetricFormatter

Default training metric formatter.

This class sorts the metrics as follows:

  1. The metrics are first divided into groups according to the suffices of their names as follows:
    1. Names ending with “time” or “timer” should come the first;
    2. Other metrics should come the second;
    3. Names ending with “loss” or “cost” should come the third;
    4. Names ending with “acc”, “accuracy”, “nll”, “lb” or “lower_bound” should come the fourth.
  2. The metrics are then sorted according to their names, within each group.

The values of the metrics would be formatted into 6-digit real numbers, except for metrics with “time” or “timer” as suffices in their names, which would be formatted using humanize_duration().

Attributes Summary

METRIC_ORDERS

Methods Summary

format_metric(name, value) Format the value of specified metric.
sort_metrics(names) Sort the names of metrics.

Attributes Documentation

METRIC_ORDERS = ((-1, <_sre.SRE_Pattern object>), (998, <_sre.SRE_Pattern object>), (999, <_sre.SRE_Pattern object at 0x59f6f40>))

Methods Documentation

format_metric(name, value)

Format the value of specified metric.

Parameters:
  • name – Name of the metric.
  • value – Value of the metric.
Returns:

Human readable string representation of the metric value.

Return type:

str

sort_metrics(names)

Sort the names of metrics.

Parameters:names – Iterable metric names.
Returns:Sorted metric names.
Return type:list[str]