Skip to content

Commit

Permalink
Use searchsorted over argmax (#9670)
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca authored Sep 23, 2021
1 parent 568a1e0 commit 2b2537d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pytorch_lightning/loops/batch/training_batch_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ def get_active_optimizers(self, batch_idx: Optional[int] = None) -> List[Tuple[i
current_place_in_loop = batch_idx % optimizers_loop_length

# find optimzier index by looking for the first {item > current_place} in the cumsum list
opt_idx = int(np.argmax(self.optimizer_freq_cumsum > current_place_in_loop))
opt_idx = np.searchsorted(self.optimizer_freq_cumsum, current_place_in_loop, side="right")
return [(opt_idx, self.trainer.optimizers[opt_idx])]

0 comments on commit 2b2537d

Please sign in to comment.