gigl.src.common.modeling_task_specs.utils.early_stop#

Attributes#

Classes#

EarlyStopper

Handles early stopping logic, keeping track of the best performing model provided some criterion

Module Contents#

class gigl.src.common.modeling_task_specs.utils.early_stop.EarlyStopper(early_stop_patience, should_maximize, model=None)[source]#

Handles early stopping logic, keeping track of the best performing model provided some criterion

Parameters:
  • early_stop_patience (int) – Maximum allowed number of steps for consecutive decreases in performance

  • should_maximize (bool) – Whether we minimize or maximize the provided criterion

  • model (Optional[nn.Module]) – Optional model to provide to early stopper class. If provided, will keep track of the state dict of the best model.

step(value)[source]#

Steps through the early stopper provided some criterion. Returns whether the provided criterion improved over the previous best criterion and whether we should early stop. :param value: Criterion used for stepping through early stopper :type value: float

Returns:

Whether there was improvement over previous best criterion bool: Whether early stop patience has been reached, indicating early stopping

Return type:

bool

Parameters:

value (float)

property best_criterion: float[source]#
Return type:

float

property best_model_state_dict: dict[str, torch.Tensor] | None[source]#
Return type:

Optional[dict[str, torch.Tensor]]

gigl.src.common.modeling_task_specs.utils.early_stop.logger[source]#