mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/SPATZ.git
synced 2025-06-10 18:15:59 +00:00
21 lines
629 B
Python
21 lines
629 B
Python
from numpy.typing import ArrayLike
|
|
from spatz.metrics import Metric
|
|
|
|
|
|
class MaxAbsDeviation(Metric):
|
|
def __init__(self) -> None:
|
|
"""A metric tracking the maximum absolute deviation from the true value."""
|
|
super().__init__()
|
|
|
|
def _update(self, x: ArrayLike, y: ArrayLike):
|
|
self._score = max(self._score, abs(x - y))
|
|
|
|
|
|
class MaxRelDeviation(Metric):
|
|
def __init__(self) -> None:
|
|
"""A metric tracking the maximum deviation from the true value in percent."""
|
|
super().__init__()
|
|
|
|
def _update(self, x: ArrayLike, y: ArrayLike):
|
|
self._score = max(self._score, (x - y) / y)
|