In Lesson 9 on Callbacks I’m really struggling to understand what the class Runner
is doing and how it interacts with the refactored Callback
class.
Problem 1. What does this code do in class Callback
?
def set_runner(self, run):
self.run=run
def __getattr__(self, k):
return getattr(self.run, k)
The callbacks get access to the Runner
that they are passed to? Then do all attributes of the Callback become self.run.attr
instead of self.attr
?
Problem 2. Looking at the class AvgStatsCallback
it references an attribute self.in_train
, but this doesn’t get set in this class or its parent class. It seems that it gets set in another callback class TrainEvalCallback
, which is called by default by Runner
, right? I could only figure that out from the source code. If I’m writing my own Callback subclass is there some contract of attributes that I can rely upon existing?
Thanks.