<jupyter_start><jupyter_text>Additional training functions [`train`](/train.htmltrain) provides a number of extension methods that are added to [`Learner`](/basic_train.htmlLearner) (see below for a list and details), along with three simple callbacks:- [`ShowGraph`](/train.htmlShowGraph)- [`GradientClipping`](/train.htmlGradientClipping)- [`BnFreeze`](/train.htmlBnFreeze)<jupyter_code>from fastai.gen_doc.nbdoc import *
from fastai.train import *
from fastai.docs import *<jupyter_output><empty_output><jupyter_text>[`Learner`](/basic_train.htmlLearner) extension methods These methods are automatically added to all [`Learner`](/basic_train.htmlLearner) objects created after importing this module. They provide convenient access to a number of callbacks, without requiring them to be manually created.<jupyter_code>show_doc(fit_one_cycle)<jupyter_output><empty_output><jupyter_text>Fit a model with 1cycle training. See [`OneCycleScheduler`](/callbacks.one_cycle.htmlOneCycleScheduler) for details.<jupyter_code>show_doc(lr_find)<jupyter_output><empty_output><jupyter_text>See [`LRFinder`](/callbacks.lr_finder.htmlLRFinder) for details.<jupyter_code>show_doc(to_fp16)<jupyter_output><empty_output><jupyter_text>See [`MixedPrecision`](/callbacks.fp16.htmlMixedPrecision) for details.<jupyter_code>show_doc(ShowGraph)
data = get_mnist()
learn = ConvLearner(data, tvm.resnet18, metrics=accuracy, callback_fns=ShowGraph)
learn.fit(3)<jupyter_output><empty_output><jupyter_text>![Training graph](imgs/train_graph.gif)  Internal callback implementation<jupyter_code>show_doc(ShowGraph.on_epoch_end)
show_doc(GradientClipping)<jupyter_output><empty_output><jupyter_text>Clips gradient at a maximum absolute value of `clip` during training. For instance:<jupyter_code>learn = ConvLearner(data, tvm.resnet18, metrics=accuracy,
    callback_fns=partial(GradientClipping, clip=0.1))
learn.fit(1)<jupyter_output><empty_output><jupyter_text>Internal callback implementation<jupyter_code>show_doc(GradientClipping.on_backward_end)
show_doc(BnFreeze)<jupyter_output><empty_output><jupyter_text>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).<jupyter_code>learn = ConvLearner(data, tvm.resnet18, metrics=accuracy, callback_fns=BnFreeze)
learn.fit(1)<jupyter_output><empty_output><jupyter_text>Internal callback implementation<jupyter_code>show_doc(BnFreeze.on_epoch_begin)<jupyter_output><empty_output><jupyter_text>Undocumented Methods - Methods moved below this line will intentionally be hidden<jupyter_code>show_doc(one_cycle_scheduler)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10190409026798307, 'fraction_numerical': 0.005641748942172073, 'mean_word_length': 10.393574297188755, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '44704', 'license': 'Apache-2.0', 'n_tokens_mistral': 964, 'n_tokens_neox': 918, 'n_words': 184, 'path': 'docs_src/train.ipynb', 'repo_name': 'Gokkulnath/fastai_v1', 'size': '2836'}