Skip to content

Commit

Permalink
Workaround for #27758 to avoid ZeroDivisionError (#28756)
Browse files Browse the repository at this point in the history
  • Loading branch information
tleyden authored Mar 4, 2024
1 parent 704b3f7 commit c38a122
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,8 @@ def _inner_training_loop(

# add remaining tr_loss
self._total_loss_scalar += tr_loss.item()
train_loss = self._total_loss_scalar / self.state.global_step
effective_global_step = max(self.state.global_step, 0.001) # Avoid ZeroDivisionError
train_loss = self._total_loss_scalar / effective_global_step

metrics = speed_metrics(
"train",
Expand Down

0 comments on commit c38a122

Please sign in to comment.