{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Tracking Callbacks" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *\n", "from fastai.vision import *\n", "from fastai.callbacks import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This module regroups the callbacks that track one of the metrics computed at the end of each epoch to take some decision about training. To show examples of use, we'll use our sample of MNIST and a simple cnn model." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "path = untar_data(URLs.MNIST_SAMPLE)\n", "data = ImageDataBunch.from_folder(path)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "
class
TerminateOnNaNCallback
[source][test]TerminateOnNaNCallback
() :: [`Callback`](/callback.html#Callback)\n",
"\n",
"No tests found for TerminateOnNaNCallback
. To contribute a test please refer to this guide and this discussion.
epoch | \n", "train_loss | \n", "valid_loss | \n", "accuracy | \n", "time | \n", "
---|---|---|---|---|
1 | \n", "nan | \n", "nan | \n", "0.495584 | \n", "00:02 | \n", "
epoch | \n", "train_loss | \n", "valid_loss | \n", "accuracy | \n", "time | \n", "
---|
\n", "\n", "
on_batch_end
[source][test]on_batch_end
(**`last_loss`**, **`epoch`**, **`num_batch`**, **\\*\\*`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.
class
EarlyStoppingCallback
[source][test]EarlyStoppingCallback
(**`learn`**:[`Learner`](/basic_train.html#Learner), **`monitor`**:`str`=***`'valid_loss'`***, **`mode`**:`str`=***`'auto'`***, **`min_delta`**:`int`=***`0`***, **`patience`**:`int`=***`0`***) :: [`TrackerCallback`](/callbacks.tracker.html#TrackerCallback)\n",
"\n",
"No tests found for EarlyStoppingCallback
. To contribute a test please refer to this guide and this discussion.
epoch | \n", "train_loss | \n", "valid_loss | \n", "accuracy | \n", "time | \n", "
---|---|---|---|---|
1 | \n", "0.677729 | \n", "0.677514 | \n", "0.560353 | \n", "00:02 | \n", "
2 | \n", "0.679820 | \n", "0.677514 | \n", "0.560353 | \n", "00:02 | \n", "
3 | \n", "0.679434 | \n", "0.677514 | \n", "0.560353 | \n", "00:02 | \n", "
4 | \n", "0.679893 | \n", "0.677514 | \n", "0.560353 | \n", "00:02 | \n", "
\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_end
[source][test]on_epoch_end
(**`epoch`**, **\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_epoch_end
. To contribute a test please refer to this guide and this discussion.
class
SaveModelCallback
[source][test]SaveModelCallback
(**`learn`**:[`Learner`](/basic_train.html#Learner), **`monitor`**:`str`=***`'valid_loss'`***, **`mode`**:`str`=***`'auto'`***, **`every`**:`str`=***`'improvement'`***, **`name`**:`str`=***`'bestmodel'`***) :: [`TrackerCallback`](/callbacks.tracker.html#TrackerCallback)\n",
"\n",
"No tests found for SaveModelCallback
. To contribute a test please refer to this guide and this discussion.
on_epoch_end
[source][test]on_epoch_end
(**`epoch`**:`int`, **\\*\\*`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`**)\n",
"\n",
"No tests found for on_train_end
. To contribute a test please refer to this guide and this discussion.
class
ReduceLROnPlateauCallback
[source][test]ReduceLROnPlateauCallback
(**`learn`**:[`Learner`](/basic_train.html#Learner), **`monitor`**:`str`=***`'valid_loss'`***, **`mode`**:`str`=***`'auto'`***, **`patience`**:`int`=***`0`***, **`factor`**:`float`=***`0.2`***, **`min_delta`**:`int`=***`0`***) :: [`TrackerCallback`](/callbacks.tracker.html#TrackerCallback)\n",
"\n",
"No tests found for ReduceLROnPlateauCallback
. To contribute a test please refer to this guide and this discussion.
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_end
[source][test]on_epoch_end
(**`epoch`**, **\\*\\*`kwargs`**:`Any`)\n",
"\n",
"No tests found for on_epoch_end
. To contribute a test please refer to this guide and this discussion.
class
TrackerCallback
[source][test]TrackerCallback
(**`learn`**:[`Learner`](/basic_train.html#Learner), **`monitor`**:`str`=***`'valid_loss'`***, **`mode`**:`str`=***`'auto'`***) :: [`LearnerCallback`](/basic_train.html#LearnerCallback)\n",
"\n",
"No tests found for TrackerCallback
. To contribute a test please refer to this guide and this discussion.
get_monitor_value
[source][test]get_monitor_value
()\n",
"\n",
"No tests found for get_monitor_value
. To contribute a test please refer to this guide and this discussion.
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.