Shortcuts

ProgressBarBase

class pytorch_lightning.callbacks.ProgressBarBase[source]

Bases: pytorch_lightning.callbacks.callback.Callback

The base class for progress bars in Lightning. It is a Callback that keeps track of the batch progress in the Trainer. You should implement your highly custom progress bars with this as the base class.

Example:

class LitProgressBar(ProgressBarBase):

    def __init__(self):
        super().__init__()  # don't forget this :)
        self.enable = True

    def disable(self):
        self.enable = False

    def on_train_batch_end(self, trainer, pl_module, outputs, batch_idx):
        super().on_train_batch_end(trainer, pl_module, outputs, batch_idx)  # don't forget this :)
        percent = (self.train_batch_idx / self.total_train_batches) * 100
        sys.stdout.flush()
        sys.stdout.write(f'{percent:.01f} percent complete \r')

bar = LitProgressBar()
trainer = Trainer(callbacks=[bar])
disable()[source]

You should provide a way to disable the progress bar.

Return type

None

enable()[source]

You should provide a way to enable the progress bar.

The Trainer will call this in e.g. pre-training routines like the learning rate finder. to temporarily enable and disable the main progress bar.

Return type

None

get_metrics(trainer, pl_module)[source]

Combines progress bar metrics collected from the trainer with standard metrics from get_standard_metrics. Implement this to override the items displayed in the progress bar.

Here is an example of how to override the defaults:

def get_metrics(self, trainer, model):
    # don't show the version number
    items = super().get_metrics(trainer, model)
    items.pop("v_num", None)
    return items
Return type

Dict[str, Union[str, int]]

Returns

Dictionary with the items to be displayed in the progress bar.

print(*args, **kwargs)[source]

You should provide a way to print without breaking the progress bar.

Return type

None

setup(trainer, pl_module, stage=None)[source]

Called when fit, validate, test, predict, or tune begins.

Return type

None

property predict_batch_idx: int

The number of batches processed during prediction.

Use this to update your progress bar.

Return type

int

property test_batch_idx: int

The number of batches processed during testing.

Use this to update your progress bar.

Return type

int

property total_predict_batches_current_dataloader: Union[int, float]

The total number of prediction batches, which may change from epoch to epoch for current dataloader.

Use this to set the total number of iterations in the progress bar. Can return inf if the predict dataloader is of infinite size.

Return type

Union[int, float]

property total_test_batches_current_dataloader: Union[int, float]

The total number of testing batches, which may change from epoch to epoch for current dataloader.

Use this to set the total number of iterations in the progress bar. Can return inf if the test dataloader is of infinite size.

Return type

Union[int, float]

property total_train_batches: Union[int, float]

The total number of training batches, which may change from epoch to epoch.

Use this to set the total number of iterations in the progress bar. Can return inf if the training dataloader is of infinite size.

Return type

Union[int, float]

property total_val_batches: Union[int, float]

The total number of validation batches, which may change from epoch to epoch for all val dataloaders.

Use this to set the total number of iterations in the progress bar. Can return inf if the predict dataloader is of infinite size.

Return type

Union[int, float]

property total_val_batches_current_dataloader: Union[int, float]

The total number of validation batches, which may change from epoch to epoch for current dataloader.

Use this to set the total number of iterations in the progress bar. Can return inf if the validation dataloader is of infinite size.

Return type

Union[int, float]

property train_batch_idx: int

The number of batches processed during training.

Use this to update your progress bar.

Return type

int

property val_batch_idx: int

The number of batches processed during validation.

Use this to update your progress bar.

Return type

int

Read the Docs v: latest
Versions
latest
stable
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.10
1.5.9
1.5.8
1.5.7
1.5.6
1.5.5
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.8
1.3.7
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.10
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.3
0.4.9
future-structure
Downloads
html
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.