Skip to content

Commit 2b2537d

Browse files
authored
Use searchsorted over argmax (#9670)
1 parent 568a1e0 commit 2b2537d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pytorch_lightning/loops/batch/training_batch_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,5 @@ def get_active_optimizers(self, batch_idx: Optional[int] = None) -> List[Tuple[i
191191
current_place_in_loop = batch_idx % optimizers_loop_length
192192

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

0 commit comments

Comments
 (0)