Train Module#

Train module.

class landmarker.train.EarlyStopping[source]#

Early stopping to stop the training when the score does not improve after certain epochs. source: https://debuggercafe.com/using-learning-rate-scheduler-and-early-stopping-with-pytorch/

Parameters:
  • patience (int, optional) – Number of epochs to wait for the score to improve. Defaults to 25.

  • min_delta (float, optional) – Minimum difference between new score and old score for new score to be considered as an improvement. Defaults to 0.0.

  • verbose (bool, optional) – Whether to print the logs or not. Defaults to False.

  • greater_is_better (bool, optional) – Whether the new score is expected to be greater than previous scores or not. Defaults to False.

  • name_score (str, optional) – Name of the score being tracked. Defaults to β€˜Val Loss’.

__init__(patience=25, min_delta=0.0, verbose=False, greater_is_better=False, name_score='Val Loss')[source]#
Parameters:
  • patience (int) –

  • min_delta (float) –

  • verbose (bool) –

  • greater_is_better (bool) –

  • name_score (str) –

class landmarker.train.SaveBestModel[source]#

Save the best model based on validation metric/loss.

Parameters:
  • verbose (bool, optional) – Whether to print the logs or not. Defaults to False.

  • greater_is_better (bool, optional) – Whether the new score is expected to be greater than previous scores or not. Defaults to False.

  • name_score (str, optional) – Name of the score being tracked. Defaults to β€˜Val Loss’.

__init__(verbose=False, greater_is_better=False, name_score='Val_Loss')[source]#
Parameters:
  • verbose (bool) –

  • greater_is_better (bool) –

  • name_score (str) –

Return type:

None

save_checkpoint(val_score, model)[source]#
Parameters:
  • val_score (float) – Validation score to compare for saving the model.

  • model (torch.nn.Module) – Model to save.

Return type:

None

landmarker.train.set_seed(seed=1817)[source]#
Set seed for reproducibility.

source: https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/How-to-Set-Random-Seeds-in-PyTorch-and-Tensorflow–VmlldzoxMDA2MDQy

Parameters:

seed (int) –

Return type:

None