Skip to content

Commit

Permalink
Workaround for huggingface#27758 to avoid ZeroDivisionError (huggingf…
Browse files Browse the repository at this point in the history
  • Loading branch information
tleyden authored and damithsenanayake committed Mar 7, 2024
1 parent ab83b95 commit ae2acb7
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 ae2acb7

Please sign in to comment.