.FluxTrainingCallback
abstract type defined in module
FluxTraining
abstract type Callback
Supertype of all callbacks. Callbacks add custom functionality to the training loop by hooking into different
Events.Events
Any
Callback can be used by passing it to
Learner. See
subtypes(FluxTraining.Callback) for implementations.
See Custom callbacks for a less succinct tutorial format.
Create a
struct MyCallback that subtypes
FluxTraining.Callback.
Add event handlers by implementing methods for
on
(event, phase, callback, learner). Methods should always dispatch on your callback, and may dispatch on specific
Phases.Phases and
Events.Events.
For example, to implement an event handler that runs at the end of every step during training:
on(::StepEnd, ::AbstractTrainingPhase, ::MyCallback, learner).
Define what state the callback accesses and/or modifies by implementing
stateaccess
(::MyCallback). While
learner is always passed as an argument to
on event handlers, by default a callback can not read or write to its fields. See
stateaccess for more detail.
If a callback needs to write some state that other callbacks should be able to access, it can store it in
learner.cbstate if you add a permission in
stateaccess.
If the callback needs some one-time initialization, you can implement
init! which will be run at least once before any step is run.
The following pages link back here:
callbacks/callback.jl , callbacks/callbacks.jl , callbacks/conditional.jl , callbacks/custom.jl , callbacks/earlystopping.jl , callbacks/logging/checkpointer.jl , callbacks/logging/logger.jl , callbacks/metrics.jl , callbacks/recorder.jl , callbacks/sanitycheck.jl , callbacks/scheduler.jl , callbacks/trace.jl , callbackutils.jl , learner.jl