Tips & tricks

Listing event handlers for a callback

Use Base.methods to check what events a callback handles:


			
			
			
			methods
			
			(
			
			
	
		
			FluxTraining
			
			.
			
			
	
		
			on
			
			,
			
			 
			
			
			(
			
			Any
			
			,
			
			 
			
			Any
			
			,
			
			 
			
	
		
			Recorder
			
			,
			
			 
			
			Any
			
			)
			
			)
# 4 methods for generic function on:

Visualize the callback dependency graph

You can use GraphPlot . jl to visualize the dependencies between callbacks:


			
			
			
			
			learner
			
			 
			
			=
			
			 
			
			
	
		
			Learner
			
			(
			
			
    
			
			nothing
			
			,
			
			 
			
			nothing
			
			,
			
			  
			
			# dummy arguments
			
			
    
			
			
			callbacks
			
			=
			
			
			[
			
			
	
		
			ToGPU
			
			(
			
			)
			
			]
			
			,
			
			

			
			)
			
			;

			
			
			
			using
			
			
			 
			
			GraphPlot
			
			

			
			
			gplot
			
			(
			
			
			
			learner
			
			.
			
			
			callbacks
			
			.
			
			
			graph
			
			,
			
			 
			
			
			nodelabel
			
			 
			
			=
			
			 
			
			
			
			learner
			
			.
			
			
			callbacks
			
			.
			
			
			cbs
			
			,
			
			 
			
			
			layout
			
			 
			
			=
			
			 
			
			stressmajorize_layout
			
			)
ToDevice(Flux.gpu, Flux.gpu) ProgressPrinter() MetricsPrinter() StopOnNaNLoss() Recorder() Metrics(Loss())

(the target of an arrow depends on the origin)

As an example for a detected dependency, we can see that MetricsPrinter runs after Metrics . MetricsPrinter prints the values of all metrics, so [ Metrics ] needs to run first.