Callback reference

Included callbacks

FluxTraining.jl comes with many callbacks included. Some of them are added to Learner by default, here marked with a *.

Callback Description
Metrics* Tracks loss and additional metrics on a per-step and per-epoch base
Recorder* Records training stats like number of steps and epochs
ProgressPrinter* Prints a progress bar for the current epoch during training
MetricsPrinter* Prints out metrics after every epoch
StopOnNaNLoss* Stops training early if a step loss is NaN
SanityCheck Performs sanity checks on data, model and loss before training
ToGPU Trains using a CUDA GPU if available
Checkpointer Saves the model after every epoch
EarlyStopping Stops training early when a criterion is met
Scheduler Schedules hyperparameters
LogMetrics Logs metrics to a logging backend
LogHyperParams Logs hyperparameters to a logging backend
LogVisualization Logs visualization to a logging backend
LogHistograms Logs model weight histograms to a logging backend

To construct a learner without default callbacks, pass usedefaultcallbacks=false when constructing it.

For working with callbacks on an existing Learner, see:

There are also some utilities for creating callbacks:

  • CustomCallback to quickly hook a function into an event

  • throttle to run a callback only after every n events or every t seconds

Extension API

The following types and functions can be used to create custom callbacks. Read the custom callbacks guide for more context.