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(begin_fit=None, begin_epoch=None, begin_train=None, begin_batch=None, after_pred=None, after_loss=None, after_backward=None, after_step=None, after_cancel_batch=None, after_batch=None, after_cancel_train=None, after_train=None, begin_validate=None, after_cancel_validate=None, after_validate=None, after_cancel_epoch=None, after_epoch=None, after_cancel_fit=None, after_fit=None) :: Callback

A Callback to handle the display of progress bars

learn = synth_learner()
learn.fit(5)
epoch train_loss valid_loss time
0 6.149214 5.585020 00:00
1 5.495753 4.248405 00:00
2 4.743536 3.020540 00:00
3 4.007711 2.104298 00:00
4 3.349151 1.430777 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,30.605850219726562,27.92107391357422,'00:00']
(#4) [1,26.819326400756836,19.888404846191406,'00:00']
(#4) [2,22.556987762451172,13.134763717651367,'00:00']
(#4) [3,18.57308578491211,8.311532020568848,'00:00']
(#4) [4,15.115865707397461,5.124312400817871,'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(begin_fit=None, begin_epoch=None, begin_train=None, begin_batch=None, after_pred=None, after_loss=None, after_backward=None, after_step=None, after_cancel_batch=None, after_batch=None, after_cancel_train=None, after_train=None, begin_validate=None, after_cancel_validate=None, after_validate=None, after_cancel_epoch=None, after_epoch=None, after_cancel_fit=None, after_fit=None) :: Callback

Update a graph of training and validation loss

learn = synth_learner(cbs=ShowGraphCallback())
learn.fit(5)
epoch train_loss valid_loss time
0 17.077604 15.280979 00:00
1 14.917645 10.782686 00:00
2 12.502088 6.969840 00:00
3 10.244695 4.306195 00:00
4 8.296035 2.599644 00:00
5 6.680259 1.545244 00:00
6 5.367113 0.914276 00:00
7 4.311401 0.539155 00:00
8 3.466442 0.317982 00:00
9 2.791286 0.188403 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 19.039587 19.701471 00:00
1 16.735422 14.259439 00:00
2 14.151361 9.632797 00:00
3 11.720305 6.176662 00:00
4 9.583822 3.861699 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.