ProgressBar¶
- class pytorch_lightning.callbacks.ProgressBar(refresh_rate=1, process_position=0)[source]¶
Bases:
pytorch_lightning.callbacks.progress.ProgressBarBaseThis is the default progress bar used by Lightning. It prints to stdout using the
tqdmpackage and shows up to four different bars:sanity check progress: the progress during the sanity check run
main progress: shows training + validation progress combined. It also accounts for multiple validation runs during training when
val_check_intervalis used.validation progress: only visible during validation; shows total progress over all validation datasets.
test progress: only active when testing; shows total progress over all test datasets.
For infinite datasets, the progress bar never ends.
If you want to customize the default
tqdmprogress bars used by Lightning, you can override specific methods of the callback class and pass your custom implementation to theTrainer:Example:
class LitProgressBar(ProgressBar): def init_validation_tqdm(self): bar = super().init_validation_tqdm() bar.set_description('running validation ...') return bar bar = LitProgressBar() trainer = Trainer(callbacks=[bar])
- Parameters
refresh_rate¶ (
int) – Determines at which rate (in number of batches) the progress bars get updated. Set it to0to disable the display. By default, theTraineruses this implementation of the progress bar and sets the refresh rate to the value provided to theprogress_bar_refresh_rateargument in theTrainer.process_position¶ (
int) – Set this to a value greater than0to offset the progress bars by this many lines. This is useful when you have progress bars defined elsewhere and want to show all of them together. This corresponds toprocess_positionin theTrainer.
- disable()[source]¶
You should provide a way to disable the progress bar. The
Trainerwill call this to disable the output on processes that have a rank different from 0, e.g., in multi-node training.- Return type
- enable()[source]¶
You should provide a way to enable the progress bar. The
Trainerwill call this in e.g. pre-training routines like the learning rate finder to temporarily enable and disable the main progress bar.- Return type
- init_sanity_tqdm()[source]¶
Override this to customize the tqdm bar for the validation sanity run.
- Return type
- on_predict_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx)[source]¶
Called when the predict batch ends.
- on_test_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx)[source]¶
Called when the test batch ends.
- on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx)[source]¶
Called when the train batch ends.