These methods are automatically added to all
Learner objects created after importing this module. They provide convenient access to a number of callbacks, without requiring them to be manually created.
slice]=`slice(None, 0.003, None)`, `moms`:
Point=`(0.95, 0.85)`, `div_factor`:
Fit a model following the 1cycle policy.
We'll show examples below using our MNIST sample. As usual the
on_something methods are directly called by the fastai library, no need to call them yourself.
path = untar_data(URLs.MNIST_SAMPLE) data = ImageDataBunch.from_folder(path)
learn = create_cnn(data, models.resnet18, metrics=accuracy, callback_fns=ShowGraph) learn.fit(3)
learn = create_cnn(data, models.resnet18, metrics=accuracy, callback_fns=partial(GradientClipping, clip=0.1)) learn.fit(1)
For batchnorm layers where
requires_grad==False, you generally don't want to update their moving average statistics, in order to avoid the model's statistics getting out of sync with its pre-trained weights. You can add this callback to automate this freezing of statistics (internally, it calls
eval on these layers).
learn = create_cnn(data, models.resnet18, metrics=accuracy, callback_fns=BnFreeze) learn.fit(1)