mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/SPATZ.git
synced 2025-08-06 18:37:34 +00:00
Added a few metrics for measuring performance
This commit is contained in:
20
spatz/metrics/max_dev.py
Normal file
20
spatz/metrics/max_dev.py
Normal file
@@ -0,0 +1,20 @@
|
||||
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)
|
Reference in New Issue
Block a user