Understanding fastai's Training Loop
fastai
's training loop is certainly unique in its approach, where everything is handled through Callbacks
. What this means is there should never be an instance where if you need to modify fastai
's training loop you are modifying Learner
's source code.
Instead we can use various trigger points through Callbacks
to get there. Currently fastai has a methodology of showing just what Callbacks
are called during the training loop through a function called Learner.show_training_loop
from fastai.callback.all import *
from fastai.test_utils import synth_learner
learn = synth_learner()
learn.show_training_loop()
As we can see, every major event is detailed with a Start
and Finish
, and the intermediate steps at each level are described. Paired with this are the Callbacks
that get triggered at that particular event.
However, I think we can take this a step further to enable you to understand just what happens during each step. As a result, I've written a revised version of Learner.show_training_loop
:
With this new version we can pass in a verbose
tag and for every Callback
and its events we will pull its documentation string, so we can see what happens at each step as shown below:
learn.show_training_loop(verbose=True)
from wwf.basics.training_loop import *
And then call learn.show_training_loop(verbose=True)