Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃挕SUG] Add progress bar to training an epoch #516

Closed
tszumowski opened this issue Nov 20, 2020 · 2 comments
Closed

[馃挕SUG] Add progress bar to training an epoch #516

tszumowski opened this issue Nov 20, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@tszumowski
Copy link

tszumowski commented Nov 20, 2020

Is your feature request related to a problem? Please describe.
When training on large datasets, it's difficult to know how far along training is and whether or not I should stop training to tweak parameters to speed up the training process.

Describe the solution you'd like
Add tqdm progress bar to training progress. See context section. I have a suggested patch to trainer.py that adds this. Happy to PR it in, or feel free to take as you see appropriate.

Describe alternatives you've considered
One alternative is a manual print. But tqdm is the standard for this typically.

Additional context

trainer.py.patch.txt

I attached a patch file that adds an optional show_progress argument in a similar manner to what's used in DataLoader already. Note: This patch only shows it for the Trainer class, not the child classes. That is because this is for an example only.

The main change is this:

-        for batch_idx, interaction in enumerate(train_data):
+        iter_data = (
+            tqdm(
+                enumerate(train_data),
+                total=len(train_data),
+                desc=f"Train {epoch_idx:>5}",
+            )
+            if show_progress
+            else enumerate(train_data)
+        )
+        for batch_idx, interaction in iter_data:

Here is an example output while training a larger dataset. Scroll right to see full output.

Trainable parameters: 735267
Train     0:  20%|鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枌                                                                                                           | 6480/31756 [10:47<42:09,  9.99it/s]
@tszumowski tszumowski added the enhancement New feature or request label Nov 20, 2020
@chenyushuo chenyushuo self-assigned this Nov 21, 2020
@chenyushuo
Copy link
Collaborator

Thanks for your insightful commment. Using tqdm is a good way to add this feature. We'd appreciate it if you would like to PR it in branch 0.1.x. By the way, any PRs are welcome.
Note: trainer.py has been refactor in #521 , be careful to add this feature.

@adebiasio-estilos
Copy link

when running the code via jupyter notebook, tqdm print all the time new lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants