Early Stopping module
- nnodely.support.earlystopping.early_stop_patience(train_losses, val_losses, params)[source]
Determines whether to stop training early based on validation loss and patience.
- Parameters:
train_losses (dict) – A dictionary where keys are epoch numbers and values are lists of training loss values.
val_losses (dict) – A dictionary where keys are epoch numbers and values are lists of validation loss values.
params (dict) – A dictionary of parameters. Should contain ‘patience’ which is the number of epochs to wait for improvement. Optionally, it can contain ‘error’ which specifies the type of loss to be used.
- Returns:
True if training should be stopped early, False otherwise.
- Return type:
bool
- nnodely.support.earlystopping.select_best_model(train_losses, val_losses, params)[source]
Selects the best model based on the validation or training losses.
- Parameters:
train_losses (dict) – A dictionary where keys are epoch numbers and values are lists of training loss values.
val_losses (dict) – A dictionary where keys are epoch numbers and values are lists of validation loss values.
params (dict) – A dictionary of parameters.
- Returns:
True if the current model is the best model, False otherwise.
- Return type:
bool
- nnodely.support.earlystopping.mean_stopping(train_losses, val_losses, params)[source]
Determines whether to stop training early based on the mean difference between training and validation losses.
- Parameters:
train_losses (dict) – A dictionary where keys are epoch numbers and values are lists of training loss values.
val_losses (dict) – A dictionary where keys are epoch numbers and values are lists of validation loss values.
params (dict) – A dictionary of parameters. Should contain ‘tol’ which is the tolerance value for early stopping.
- Returns:
True if training should be stopped early, False otherwise.
- Return type:
bool
- nnodely.support.earlystopping.standard_early_stopping(train_losses, val_losses, params)[source]
Determines whether to stop training early based on training and validation losses.
- Parameters:
train_losses (dict) – A dictionary where keys are epoch numbers and values are lists of training loss values.
val_losses (dict) – A dictionary where keys are epoch numbers and values are lists of validation loss values.
params (dict) – A dictionary of parameters. Should contain ‘tol’ which is the tolerance value for early stopping.
- Returns:
True if training should be stopped early, False otherwise.
- Return type:
bool