neuraxle.metaopt.callbacks

Neuraxle’s training callbacks classes.

Training callback classes.

Classes

BaseCallback

Base class for a training callback.

CallbackList(callbacks, print_func)

Callback list that be executed.

EarlyStoppingCallback(…)

Perform early stopping when there is multiple epochs in a row that didn’t improve the performance of the model.

IfBestScore(wrapped_callback)

Meta callback that only execute when the trial is a new best score.

IfLastStep(wrapped_callback)

Meta callback that only execute when the training is finished or fitted, or when it is the last epoch.

MetaCallback(wrapped_callback)

Meta callback wraps another callback.

MetricCallback(name, metric_function, …[, …])

Callback that calculates metric results.

ScoringCallback(metric_function, …)

Metric Callback that calculates metric results for the main scoring metric.

StepSaverCallback

Callback that saves the trial model.

class neuraxle.metaopt.callbacks.BaseCallback[source]

Base class for a training callback. Callbacks are called after each epoch inside the fit function of the Trainer.

call(trial: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.CallbackList(callbacks, print_func: Callable = None)[source]

Callback list that be executed.

call(trial: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.EarlyStoppingCallback(max_epochs_without_improvement)[source]

Perform early stopping when there is multiple epochs in a row that didn’t improve the performance of the model.

call(trial: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.IfBestScore(wrapped_callback: neuraxle.metaopt.callbacks.BaseCallback)[source]

Meta callback that only execute when the trial is a new best score.

call(trial: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.IfLastStep(wrapped_callback: neuraxle.metaopt.callbacks.BaseCallback)[source]

Meta callback that only execute when the training is finished or fitted, or when it is the last epoch.

call(trial: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.MetaCallback(wrapped_callback: neuraxle.metaopt.callbacks.BaseCallback)[source]

Meta callback wraps another callback. It can be useful to test conditions before executing certain callbacks.

call(trial: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.MetricCallback(name: str, metric_function: Callable, higher_score_is_better: bool, print_metrics=True, print_function=None)[source]

Callback that calculates metric results. Adds the results into the trial repository.

call(trial: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, is_finished_and_fitted: bool)[source]
class neuraxle.metaopt.callbacks.ScoringCallback(metric_function: Callable, higher_score_is_better: bool)[source]

Metric Callback that calculates metric results for the main scoring metric. Adds the results into the trial repository.

class neuraxle.metaopt.callbacks.StepSaverCallback[source]

Callback that saves the trial model.

call(trial: neuraxle.metaopt.trial.TrialSplit, epoch_number: int, total_epochs: int, input_train: neuraxle.data_container.DataContainer, pred_train: neuraxle.data_container.DataContainer, input_val: neuraxle.data_container.DataContainer, pred_val: neuraxle.data_container.DataContainer, is_finished_and_fitted: bool)[source]