Callback and helper function to track progress of training or log results
/usr/local/lib/python3.8/dist-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at  /pytorch/c10/cuda/CUDAFunctions.cpp:100.)
  return torch._C._cuda_getDeviceCount() > 0
from fastai.test_utils import *

class ProgressCallback[source]

ProgressCallback(after_create=None, before_fit=None, before_epoch=None, before_train=None, before_batch=None, after_pred=None, after_loss=None, before_backward=None, before_step=None, after_cancel_step=None, after_step=None, after_cancel_batch=None, after_batch=None, after_cancel_train=None, after_train=None, before_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 8.960221 8.501486 00:00
1 7.650368 5.475908 00:00
2 6.193127 3.202425 00:00
3 4.902714 1.781969 00:00
4 3.847687 0.968699 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)
[0, 16.774219512939453, 16.614517211914062, '00:00']
[1, 14.62364387512207, 11.538640975952148, '00:00']
[2, 12.198295593261719, 7.462512016296387, '00:00']
[3, 9.962362289428711, 4.619643688201904, '00:00']
[4, 8.045241355895996, 2.791717052459717, '00:00']

ProgressCallback.before_fit[source]

ProgressCallback.before_fit()

Setup the master bar over the epochs

ProgressCallback.before_epoch[source]

ProgressCallback.before_epoch()

Update the master bar

ProgressCallback.before_train[source]

ProgressCallback.before_train()

Launch a progress bar over the training dataloader

ProgressCallback.before_validate[source]

ProgressCallback.before_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(after_create=None, before_fit=None, before_epoch=None, before_train=None, before_batch=None, after_pred=None, after_loss=None, before_backward=None, before_step=None, after_cancel_step=None, after_step=None, after_cancel_batch=None, after_batch=None, after_cancel_train=None, after_train=None, before_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 11.676161 8.622957 00:00
1 10.183996 6.069672 00:00
2 8.519948 3.890609 00:00
3 6.959560 2.382288 00:00
4 5.621220 1.414858 00:00
learn.predict(torch.tensor([[0.1]]))
(tensor([1.9139]), tensor([1.9139]), tensor([1.9139]))

class CSVLogger[source]

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

Log the results displayed in learn.path/fname

The results are appended 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 10.500990 8.331024 00:00
1 9.115092 5.783391 00:00
2 7.573916 3.695323 00:00
3 6.161108 2.222861 00:00
4 4.948495 1.308835 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.before_fit[source]

CSVLogger.before_fit()

Prepare file with metric names.

CSVLogger.after_fit[source]

CSVLogger.after_fit()

Close the file and clean up.