Exemplo n.º 1
0
    def consume(
        self,
        name: str,
        metric: Metric,
        iteration: Union[str, IterationType, int] = IterationType.AUTO,
    ):
        r"""Shortcut for logging and resetting metric in one call

        Shortcut for common scenario. Computes metric value, logs it and then resets it to prepare
        for new updates.

        If you don't need reset call ordinary :meth:`log`::

            metrics.log(name, metric.compute(),...)

        Args:
            name: Metric name
            metric: Metric object to log and reset
            iteration: Iteration on which metric is recorded. See Note
        Returns:
              None
        """
        self.log(name, metric.compute(), iteration=iteration)
        metric.reset()
Exemplo n.º 2
0
def test_abstract_class():
    with raises(TypeError):
        Metric()
Exemplo n.º 3
0
 def __init__(self, output_transform=lambda x: x):
     Metric.__init__(self, output_transform=output_transform)
     self.reset()
Exemplo n.º 4
0
 def __init__(self):
     self.values: List[Tuple[int, T]]
     Metric.__init__(self)
Exemplo n.º 5
0
 def __init__(self, output_transform=lambda x: x, log_interval=100):
     self.model_state = Message()
     Metric.__init__(self, output_transform=output_transform)
     self.log_interval = log_interval