Metric#
- class brainstate.nn.Metric#
Base class for metrics.
Any class that subclasses
Metricshould implementcompute,reset, andupdatemethods to track and compute evaluation metrics.Notes
This is an abstract base class and should not be instantiated directly. Subclasses must implement all three methods.
- compute()[source]#
Compute and return the current value of the metric.
- Returns:
The computed metric value. The type depends on the specific metric.
- Return type:
metric_value
- Raises:
NotImplementedError – If the subclass does not implement this method.
- reset()[source]#
In-place reset the metric state to initial values.
This method should restore all internal state variables to their initial values as if the metric was just constructed.
- Raises:
NotImplementedError – If the subclass does not implement this method.
- Return type:
- update(**kwargs)[source]#
In-place update the metric with new data.
- Parameters:
**kwargs – Keyword arguments containing the data to update the metric. The specific arguments depend on the metric implementation.
- Raises:
NotImplementedError – If the subclass does not implement this method.
- Return type: