TrainingHistory#

class pyqit.core.TrainingHistory[source]#

Bases: object

Metrics recorded once per epoch, backend-agnostic.

train_loss, val_loss, train_acc, val_acc

One entry per completed epoch. val_* are NaN without a validation split.

Type:

list of float

epoch_times#

Wall-clock seconds per epoch.

Type:

list of float

best_epoch#

Epoch with the best score.

Type:

int

best_score#

That epoch’s value of best_metric.

Type:

float

best_metric#

Which metric the best epoch was chosen on: val_loss when a validation split exists, train_loss otherwise. NaN loses every comparison, so monitoring val_loss unconditionally left a run without a validation split reporting inf @ epoch 0.

Type:

{“val_loss”, “train_loss”}

as_dict() → dict[str, list[float]][source]#

The recorded series, keyed by metric name.

record(epoch: int, train_loss: float, val_loss: float = nan, train_acc: float = 0.0, val_acc: float = 0.0, epoch_time: float = 0.0) → None[source]#

Append one epoch’s metrics and update the running best.

Parameters:
  • epoch (int) – Zero-based epoch index.

  • train_loss (float) – Mean training loss over the epoch.

  • val_loss (float, default NaN) – Validation loss; NaN means the run has no validation split.

  • train_acc (float, default 0.0) – Accuracies for the epoch.

  • val_acc (float, default 0.0) – Accuracies for the epoch.

  • epoch_time (float, default 0.0) – Wall-clock seconds the epoch took.