Metric#

class brainstate.nn.Metric#

Base class for metrics.

Any class that subclasses Metric should implement compute, reset, and update methods to track and compute evaluation metrics.

reset()[source]#

Reset the metric state to initial values.

update(**kwargs)[source]#

Update the metric state with new data.

compute()[source]#

Compute and return the current metric value.

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:

None

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:

None