Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fix, remove t_mul passing to CosineLRScheduler #315

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lr_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def build_scheduler(config, optimizer, n_iter_per_epoch):
lr_scheduler = CosineLRScheduler(
optimizer,
t_initial=(num_steps - warmup_steps) if config.TRAIN.LR_SCHEDULER.WARMUP_PREFIX else num_steps,
t_mul=1.,
lr_min=config.TRAIN.MIN_LR,
warmup_lr_init=config.TRAIN.WARMUP_LR,
warmup_t=warmup_steps,
Expand Down Expand Up @@ -118,7 +117,7 @@ def get_update_values(self, num_updates: int):
class MultiStepLRScheduler(Scheduler):
def __init__(self, optimizer: torch.optim.Optimizer, milestones, gamma=0.1, warmup_t=0, warmup_lr_init=0, t_in_epochs=True) -> None:
super().__init__(optimizer, param_group_field="lr")

self.milestones = milestones
self.gamma = gamma
self.warmup_t = warmup_t
Expand All @@ -129,9 +128,9 @@ def __init__(self, optimizer: torch.optim.Optimizer, milestones, gamma=0.1, warm
super().update_groups(self.warmup_lr_init)
else:
self.warmup_steps = [1 for _ in self.base_values]

assert self.warmup_t <= min(self.milestones)

def _get_lr(self, t):
if t < self.warmup_t:
lrs = [self.warmup_lr_init + t * s for s in self.warmup_steps]
Expand Down