I’m writing a little toy example to better understand custom callbacks and ran into a few questions. I wrote the following that saves model weights after each epoch.
I’m getting the expected output – which is the model weights to be saved to disk after each epoch. But my questions are:
Is it possible to pass in function arguments to SaveModel when calling the callback? So as a trivial example, what if I wanted to pass a model name prefix into on_epoch_end while creating learn. Where would I do this?
What is the difference between passing callback_fns and callbacks into the learner object?
and then you can access this argument through self.arg in every function.
A callback function is a Callback that takes a Learner, it will be created when you call fit and at the same time, become an attribute of the Learner like learn.recorder which can be useful if you want to access it later.
Every callback that is passed to Learner with the callback_fns parameter will be automatically stored as an attribute. The attribute name is snake-cased, so for instance ActivationStats will appear as learn.activation_stats (assuming your object is named learn ).