{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Classes for callback implementors" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *\n", "from fastai.callback import * \n", "from fastai.basics import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "fastai provides a powerful *callback* system, which is documented on the [`callbacks`](/callbacks.html#callbacks) page; look on that page if you're just looking for how to use existing callbacks. If you want to create your own, you'll need to use the classes discussed below.\n", "\n", "A key motivation for the callback system is that additional functionality can be entirely implemented in a single callback, so that it's easily read. By using this trick, we will have different methods categorized in different callbacks where we will find clearly stated all the interventions the method makes in training. For instance in the [`LRFinder`](/callbacks.lr_finder.html#LRFinder) callback, on top of running the fit function with exponentially growing LRs, it needs to handle some preparation and clean-up, and all this code can be in the same callback so we know exactly what it is doing and where to look if we need to change something.\n", "\n", "In addition, it allows our [`fit`](/basic_train.html#fit) function to be very clean and simple, yet still easily extended. So far in implementing a number of recent papers, we haven't yet come across any situation where we had to modify our training loop source code - we've been able to use callbacks every time." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "
class
Callback
[source][test]Callback
()\n",
"\n",
"on_train_begin
[source][test]on_train_begin
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_train_begin
. To contribute a test please refer to this guide and this discussion.
on_epoch_begin
[source][test]on_epoch_begin
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_epoch_begin
. To contribute a test please refer to this guide and this discussion.
on_batch_begin
[source][test]on_batch_begin
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_batch_begin
. To contribute a test please refer to this guide and this discussion.
on_loss_begin
[source][test]on_loss_begin
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_loss_begin
. To contribute a test please refer to this guide and this discussion.
on_backward_begin
[source][test]on_backward_begin
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_backward_begin
. To contribute a test please refer to this guide and this discussion.
on_backward_end
[source][test]on_backward_end
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_backward_end
. To contribute a test please refer to this guide and this discussion.
on_step_end
[source][test]on_step_end
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_step_end
. To contribute a test please refer to this guide and this discussion.
on_batch_end
[source][test]on_batch_end
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_batch_end
. To contribute a test please refer to this guide and this discussion.
on_epoch_end
[source][test]on_epoch_end
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_epoch_end
. To contribute a test please refer to this guide and this discussion.
on_train_end
[source][test]on_train_end
(**\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_train_end
. To contribute a test please refer to this guide and this discussion.
get_state
[source][test]get_state
(**`minimal`**:`bool`=***`True`***)\n",
"\n",
"No tests found for get_state
. To contribute a test please refer to this guide and this discussion.