Args: patience (int): How long to wait after last time validation loss improved. Default: 20 min_epochs (int): Earliest epoch possible for stopping verbose (bool): If True, prints a message for each validation loss improvement.
(self, patience=15, min_epochs=20, saving_checkpoint=True)
| 100 | class MonitorBestModelEarlyStopping: |
| 101 | """Early stops the training if validation loss doesn't improve after a given patience and save best model """ |
| 102 | def __init__(self, patience=15, min_epochs=20, saving_checkpoint=True): |
| 103 | """ |
| 104 | Args: |
| 105 | patience (int): How long to wait after last time validation loss improved. |
| 106 | Default: 20 |
| 107 | min_epochs (int): Earliest epoch possible for stopping |
| 108 | verbose (bool): If True, prints a message for each validation loss improvement. |
| 109 | Default: False |
| 110 | """ |
| 111 | #self.warmup = warmup |
| 112 | self.patience = patience |
| 113 | self.min_epochs = min_epochs |
| 114 | self.counter = 0 |
| 115 | self.early_stop = False |
| 116 | |
| 117 | self.eval_loss_min = np.Inf |
| 118 | self.best_loss_score = None |
| 119 | self.best_epoch_loss = None |
| 120 | |
| 121 | self.best_CI_score = 0.0 |
| 122 | self.best_metrics_score = None |
| 123 | self.best_epoch_CI = None |
| 124 | |
| 125 | self.saving_checkpoint = saving_checkpoint |
| 126 | |
| 127 | def __call__(self, epoch, eval_loss, eval_cindex, eval_other_metrics, model, log_dir): |
| 128 |
nothing calls this directly
no outgoing calls
no test coverage detected