Callback and helper function to track progress of training or log results
from nbdev.showdoc import *
from fastai2.test_utils import *

class ProgressCallback[source]

ProgressCallback() :: Callback

A Callback to handle the display of progress bars

learn = synth_learner()
learn.fit(5)
epoch train_loss valid_loss time
0 24.803564 19.402828 00:00
1 21.064993 12.958580 00:00
2 17.115129 7.598840 00:00
3 13.544937 4.205079 00:00
4 10.624330 2.241188 00:00

Learner.no_bar[source]

Learner.no_bar()

Context manager that deactivates the use of progress bars

learn = synth_learner()
with learn.no_bar(): learn.fit(5)
(#4) [0,24.763446807861328,21.252344131469727,'00:00']
(#4) [1,21.242263793945312,14.35609245300293,'00:00']
(#4) [2,17.463743209838867,8.522371292114258,'00:00']
(#4) [3,13.958580017089844,4.946532249450684,'00:00']
(#4) [4,11.093666076660156,2.65022873878479,'00:00']

ProgressCallback.begin_fit[source]

ProgressCallback.begin_fit()

Setup the master bar over the epochs

ProgressCallback.begin_epoch[source]

ProgressCallback.begin_epoch()

Update the master bar

ProgressCallback.begin_train[source]

ProgressCallback.begin_train()

Launch a progress bar over the training dataloader

ProgressCallback.begin_validate[source]

ProgressCallback.begin_validate()

Launch a progress bar over the validation dataloader

ProgressCallback.after_batch[source]

ProgressCallback.after_batch()

Update the current progress bar

ProgressCallback.after_train[source]

ProgressCallback.after_train()

Close the progress bar over the training dataloader

ProgressCallback.after_validate[source]

ProgressCallback.after_validate()

Close the progress bar over the validation dataloader

ProgressCallback.after_fit[source]

ProgressCallback.after_fit()

Close the master bar

class ShowGraphCallback[source]

ShowGraphCallback() :: Callback

Update a graph of training and validation loss

learn = synth_learner(cbs=ShowGraphCallback())
learn.fit(10)
epoch train_loss valid_loss time
0 14.383755 13.060007 00:00
1 12.422895 9.005208 00:00
2 10.291282 5.540675 00:00
3 8.310378 3.252304 00:00
4 6.636825 1.849871 00:00
5 5.276352 1.039516 00:00
6 4.191889 0.584936 00:00
7 3.336323 0.331637 00:00
8 2.663370 0.186069 00:00
9 2.132213 0.106666 00:00

class CSVLogger[source]

CSVLogger(fname='history.csv', append=False) :: Callback

Basic class handling tweaks of the training loop by changing a Learner in various events

The results are appened to an existing file if append, or they overwrite it otherwise.

learn = synth_learner(cbs=CSVLogger())
learn.fit(5)
epoch train_loss valid_loss time
0 13.575512 15.007103 00:00
1 11.888121 10.582724 00:00
2 9.983163 6.954432 00:00
3 8.199842 4.460877 00:00
4 6.674955 2.722394 00:00

CSVLogger.read_log[source]

CSVLogger.read_log()

Convenience method to quickly access the log.

df = learn.csv_logger.read_log()
test_eq(df.columns.values, learn.recorder.metric_names)
for i,v in enumerate(learn.recorder.values):
    test_close(df.iloc[i][:3], [i] + v)
os.remove(learn.path/learn.csv_logger.fname)

CSVLogger.begin_fit[source]

CSVLogger.begin_fit()

Prepare file with metric names.

CSVLogger.after_fit[source]

CSVLogger.after_fit()

Close the file and clean up.