Understanding last_epoch usage in optim.lr_scheduler.CyclicLR

I am trying to use CyclicLR but I’m confused by the documentation, which seems to stress last_epoch is more like num_batches_seen as opposed to the last epoch#. I don’t see this in other classes that inherit from _LRScheduler.

image

Following the code, it’s not clear to me if last_epoch here is actually the number of batches computed.

My best guess is that the argument was just reused to be compatible with the base class, which uses self.last_epoch.
Since other schedulers are supposed to be called once per epoch, I assume this name was used initially.
Once CyclicLR, which is supposed to be called after each batch, was written, the ship has sailed and this argument name was reused.

I haven’t worked on the implementation, so I might be completely wrong, but that’s my understanding based on the code.

1 Like