Lesson 9 Discussion & Wiki (2019)

The DataBlock API and the callbacks in fastai is imho, what makes fastai the best DL library around today!

SaveBestModelCallback FTW btw.

3 Likes

Is there a clear documentation about different Callbacks presented in the official Fastai documentation?

2 Likes

Any chance we’ll get to implement distributed nn training using async callbacks?

A LearnerCallback is a Callback that requires access to the Learner. That creates a cyclical reference (which is bad in general) so we have some extra beahvior to deal with it (a weak reference mainly).

TrackerCallbacb is just a template for callbacks that want need to track a metric.

3 Likes

https://docs.fast.ai/callbacks.html

2 Likes

Was the idea of callbacks brought from another library? Just curious where that actually came from

There is a difference between async cuda calls and our Callback system (which happens after those async calls). I don’t think it’ll be covered in this course.

Why can’t the learner be a Named Tuple as opposed to a class since it only storage container?

Keras has callbacks also, I guess. Though probably they are a bit different.

2 Likes

The basic inspiration was the Keras callback system, then we just made it better.

6 Likes

If it was a named tuple, we woudl’nt be able to modify its attributes outside of the training loop, in a callback, without the training loop being aware of the changes.

place i get stopped is
how do i access below stuff in Callbacks

  1. Last metrics
  2. Last loss
  3. based on above details do some stuffs like load with different weights,modify LRs

I did a quick search for tensorboard in docs.fast.ai and came up with no results. Anyone have some links to tensorboard integration if it is built-in or a guide if it is something we have to do manually?

So are callbacks just used to tell you what step you are on? Like it’s basically just an if condition?

What is the difference between hooks in pytorch and callbacks in fastai?

3 Likes

They basically let you inject custom things at various points the middle of your training loop.

2 Likes

Ah I see …

There are a number of posts on the forums that discuss these things specifically … so search there first. Second, the thing that was most helpful to me understanding how to build my own and even work on some of the fastai callbacks, was to go through the source code.

If there is something particular and you can’t find it on the forums, lmk.

I would say that this callback thing is somewhat similar to an arcade game loop. You have a bunch of various sub-systems (like collisions detection, positions updating, rendering, etc.) that are executed sequentially one after another with some conditional logic.

1 Like

What is the point of having this in the callback functions?
for cb in self.cbs: res = res

Hooks in PyTorch are callbacks called when you pass through a layer in a model. It lets you see the inputs and outputs of that specific layer. Our Callback system handles the training loop, so it’s for the training loop behavior.

4 Likes