spacr.qt.widgets.training_monitor

Incrementally display loss and accuracy during model training.

The widget retains one plot item per metric and updates its data as epochs complete. This preserves the current view and avoids creating overlapping plot items during long training runs.

Classes

TrainingMonitor

Display training metrics as incrementally updated curves.

Module Contents

class spacr.qt.widgets.training_monitor.TrainingMonitor(parent: PySide6.QtWidgets.QWidget | None = None)[source]

Bases: PySide6.QtWidgets.QWidget

Display training metrics as incrementally updated curves.

plots holds one pyqtgraph.PlotWidget per panel, keyed "loss", "accuracy" and "per_class". curves holds the pyqtgraph.PlotDataItem for each metric, created when that metric first appears and reused for every epoch after it.

Both are populated as epochs arrive and neither is replaced, so a reference taken once stays valid for the life of the panel.

Build the panel that follows a training run’s losses and metrics.

Parameters:

parent (QWidget, optional) – Parent widget, or None.

append(epoch: float, values: Dict[str, float]) → int[source]

Append finite metric values for one epoch.

Parameters:
  • epoch (float) – Epoch coordinate assigned to each accepted value.

  • values (dict of str to float) – Metric values keyed by series name. Names containing loss are placed on the loss panel; aggregate accuracy names are placed on the accuracy panel; other names are treated as per-class metrics. Non-numeric and non-finite values are ignored.

Returns:

int – Number of series updated.

clear() → None[source]

Remove all curves and stored points for a new training run.

points(name: str) → Tuple[Tuple[float, ...], ...][source]

Return epoch and value coordinates for a metric series.

Parameters:

name (str) – Metric series name.

Returns:

tuple of tuple of float – (epochs, values). Both tuples are empty when the series has not been observed.

series() → Tuple[str, ...][source]

Return metric names in the order they first appeared.