Lesson 9 Discussion & Wiki (2019)

hi sg,

I tried to ask on the top of thatā€¦
What i knew already was how u build the callbackā€¦
What i dint knew was what i askedā€¦hope that if some one is already doing it in any notebook ,can post the link.

Itā€™s definitely part of a useful abstraction, but my guess is that beginners will look at it and think: what the hell is happening here? Maybe a link to this part of the video will do.

I would go one further and guess that non-beginners would also think ā€œWhat the hell is happening here?ā€ It will take some major unravelling for anyone unfamiliar with the codebase to make sense of this approach.

It does eventually seem to lead to a nice API for fastai users though. That said the whole exercise just makes me miss C# Events. Iā€™m unfamiliar with Swift but perhaps it can help solve problems like this without having to search through lists of methods based on the methodā€™s string name.

2 Likes

Might just be my opinion Self(ā€˜callbackā€™) code looks very weird. Why not just have a simple function self.invoke_callback(callback_name) instead ? Might be easier to understand it that way.

1 Like

Hi mods. May I know what is Jeremyā€™s typical process in debugging the issues that he encounters during his experimentation? Would love to see the process step by step.

I have a recollection that he mentioned this sometime before - but canā€™t find the reference somehow.

Thanks in advance.

6 Likes

ā€¦ and LINQ.

I think this is where something like S4TF can be a big win.

I asked about it here, and I was indeed meaning to ask an update on it :slight_smile: so +1 on that!

1 Like

Why must the begin_fit method in the CallbackHandler class stop executing subsequent callbacks in the list if one of the prior ones returns False?

The execution will not stop, since the loop goes like for cb in self.cbs. We just record the fact that one of the functions returned False.

Also, Iā€™m having trouble wrapping my mind around the concept of a Callback as a set of callbacks ā€“ I naturally think of ā€œbegin_fitā€, ā€œafter_fitā€, etc each as a separate callback. Why would you ever need to pass in two "begin_fit"s?

We may need to do more than one things at, say, begin_fit (i.e. when fit is called). Thus, you may want multiple callbacks per event.

3 Likes

That is the main reason we develop in Jupyter Notebook. Debugging or checking your outputs is super easy and that really boosts our productivity.
And the ipython debugger is great if needed!

2 Likes

Sounds like a fun exercise :slight_smile: . I still underestimate the power of Jupyter notebooks as documentation :).

Iā€™m not sure about Jeremy ā€¦ but one thing I do frequently is copy the pertinent fastai code into my own notebook, rename the methods/classes so it doesnā€™t conflict with the fastai code, and then I sprinkle pdb.set_trace() all over and look at the shape of things in particular as code runs.

5 Likes

What does Jeremy mean by ā€œhaving the first batch right means everything is goodā€?

Did he mean that the first batch must have expected behaviour in terms of mean, std, loss, etc.? Or something more implicit that Iā€™m mising?

He means that in the first batches of training, itā€™s crucial to have the beginning of training go well. That is why we begin with a low learning rate and warm up in 1cycle.

5 Likes

As far as I know, so far the schedules are set manually. Are you aware of any research that create a schedule based on the current state of the model? In order word, that determine the ā€˜phaseā€™ the model is in by looking at it, and sets the annealing accordingly?

3 Likes

Is there a list of the available callbacks?

That would be cool wouldnā€™t it? Thatā€™s an area weā€™re researching, but no results yet.

3 Likes

Would we use a callback if we want to be setting schedules that depend on current or recent values/statistics of different layers, or is that something that requires a different approach?

Read the docs :wink: here

1 Like

Is there a way to write tests to test all these callbacks (using TDD)? Or you just try and hope it will work as expected for edge cases?

Not sure what you mean. Itā€™s easy to write a test for a Callback to make sure it did what it was supposed to do.

Shameless plugin: if youā€™re a bit rusty with decorators, Iā€™ve written a blog post on them :slight_smile:

11 Likes