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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix global_step when gradient accumulation > 1 #832

Merged
merged 1 commit into from
Feb 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pytorch_lightning/trainer/training_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,9 @@ def run_training_epoch(self):
# logs user requested information to logger
self.log_metrics(batch_step_metrics, grad_norm_dic)

self.global_step += 1
# progress global step according to grads progress
if (self.batch_idx + 1) % self.accumulate_grad_batches == 0:
Copy link
Member

@Borda Borda Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we clarify what is the meaning of these two variables?
could you pls add comment to the trainer init starting with #: so it is generated also in the documentation...
Thx

self.global_step += 1
self.total_batch_idx += 1

# end epoch early
Expand Down