deeplay.callbacks.progress Module#
Enhanced progress bars for compatibility and customization.
This module defines enhanced progress bars for PyTorch Lightning, designed to improve compatibility and usability in various environments. The TQDMProgressBar and RichProgressBar classes extend the Lightning default implementations and provide safe refresh rate handling for platforms like Google Colab and Kaggle, which may crash with small refresh rates.
Key Features#
TQDM Progress Bar with Compatibility Enhancements
The TQDMProgressBar class extends Lightning’s TQDMProgressBar, providing a mechanism to adjust refresh rates based on the execution environment. This helps avoid issues caused by small refresh rates on Colab and Kaggle.
Rich Progress Bar with Customization Options
The RichProgressBar class offers a visually appealing progress bar with customizable themes and console options. Similar to the TQDMProgressBar, it includes environment-based refresh rate adjustments to enhance stability.
Module Structure#
Classes:
TQDMProgressBar: Enhances Lightning TQDM progress bar.
Automatically modifies the refresh rate if the code is executed on platforms like Colab or Kaggle.
RichProgressBar: Enhances Lightning Rich progress bar.
Supports configurable themes and console settings, and adjusts refresh rates when needed.
Examples#
This example demosntrate the use of the standard TQDM progress bar:
```python import deeplay as dl import torch
# Create training dataset. num_samples = 10 ** 4 data = torch.randn(num_samples, 2) labels = (data.sum(dim=1) > 0).long()
dataset = torch.utils.data.TensorDataset(data, labels) dataloader = dl.DataLoader(dataset, batch_size=16, shuffle=True)
# Create neural network and classifier application. mlp = dl.MediumMLP(in_features=2, out_features=2) classifier = dl.Classifier(mlp, optimizer=dl.Adam(), num_classes=2).build()
# Train neural network with progress bar. tqdm_bar = dl.callbacks.TQDMProgressBar(refresh_rate=100) trainer = dl.Trainer(max_epochs=100, callbacks=[tqdm_bar]) trainer.fit(classifier, dataloader) ```
Alternatively, you can use the rich progress bar with:
`python
rich_bar = dl.callbacks.RichProgressBar(refresh_rate=100)
trainer = dl.Trainer(max_epochs=100, callbacks=[rich_bar])
trainer.fit(classifier, dataloader)
`
Classes#
|
alias of |
|
alias of |
|
alias of |
|
A progress bar for displaying training progress with Rich. |
|
A progress bar for displaying training progress with TQDM. |