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

StepLR and Cos has no funcion like ".get_last_lr()" #14

Open
carol007 opened this issue Jun 4, 2020 · 1 comment
Open

StepLR and Cos has no funcion like ".get_last_lr()" #14

carol007 opened this issue Jun 4, 2020 · 1 comment

Comments

@carol007
Copy link

carol007 commented Jun 4, 2020

optimizer = optim.SGD(model.parameters(), lr=lr, momentum=0.9, nesterov=True, weight_decay=0.0001) scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, max_epoch, eta_min=0, last_epoch=-1) scheduler_warmup = GradualWarmupScheduler(optimizer, multiplier=8, total_epoch=5, after_scheduler=scheduler)
AttributeError: 'CosineAnnealingLR' object has no attribute 'get_last_lr'

@LeeMonkey
Copy link

LeeMonkey commented Jun 10, 2020

optimizer = optim.SGD(model.parameters(), lr=lr, momentum=0.9, nesterov=True, weight_decay=0.0001) scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, max_epoch, eta_min=0, last_epoch=-1) scheduler_warmup = GradualWarmupScheduler(optimizer, multiplier=8, total_epoch=5, after_scheduler=scheduler)
AttributeError: 'CosineAnnealingLR' object has no attribute 'get_last_lr'

you can check if the StepLR or COS has get_last_lr function by "hasattr()", if not, replace “.get_last_lr()” to “[group['lr'] for group in self.optimizer.param_groups]”。refer:here line 97 and line 153

banben pushed a commit to banben/pytorch-gradual-warmup-lr-mod that referenced this issue Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants