splisosm.logger#

Training logger utilities for GLM/GLMM optimization.

Classes#

PatienceLogger

Logger for tracking training patience and convergence.

Module Contents#

class splisosm.logger.PatienceLogger(batch_size, patience, min_delta=1e-05, diagnose=False)#

Logger for tracking training patience and convergence.

For training MultinomGLM and MultinomGLMM.

Parameters:
  • batch_size (int) – Number of samples in the batch.

  • patience (int) – Number of epochs to wait after the last significant improvement.

  • min_delta (float) – Minimum change in the loss to qualify as an improvement.

  • diagnose (bool) – Whether to store parameter changes during training.

get_params_iter()#

Return stored parameters during training if diagnose is True.

Returns:

List of dictionaries containing loss and parameters for each sample, or None if diagnose is False.

Return type:

list[dict] or None

log(loss, params)#

Log loss for a given epoch and update best parameters if improved.

Parameters:
  • loss (Tensor) – Loss for the current epoch.

  • params (dict[str, Tensor]) – Parameters for the current epoch.

Return type:

None

batch_size#
best_epoch#
best_loss#
best_params = None#
convergence#
diagnose = False#
epoch = 0#
epochs_without_improvement#
min_delta = 1e-05#
patience#