Skip to content

Commit

Permalink
Fixed divide by zero when tuning batch size (#3481)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgaddair authored Jul 26, 2023
1 parent 279a9ba commit 446c747
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ludwig/utils/batch_size_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def evaluate(self, batch_size: int, total_steps: int = 5) -> float:
start_ts = time.time()
self.step(batch_size)
durations.append(time.time() - start_ts)

med_duration_s = statistics.median(durations)
if med_duration_s == 0.0:
return float("inf")

return batch_size / med_duration_s

def reset(self):
Expand Down

0 comments on commit 446c747

Please sign in to comment.