Hi , I´m having some trouble understanding how callbacks work , I mean I do understand what they are meant for but no how they operate. Having the following “fit” function , why does it return “for epoch in range(epochs)” if every “cb.begin_fit(learn)” callback returns a “True” statement.
def fit(epochs, learn, cb):
if not cb.begin_fit(learn): return
for epoch in range(epochs):
class CallbackHandler():
def __init__(self,cbs=None):
self.cbs = cbs if cbs else []
def begin_fit(self, learn):
self.learn,self.in_train = learn,True
learn.stop = False
res = True
for cb in self.cbs: res = res and cb.begin_fit(learn)
return res
class TestCallback(Callback):
def begin_fit(self,learn):
super().begin_fit(learn)
self.n_iters = 0
return True