Merged
Conversation
rentainhe
commented
Jan 6, 2022
flowvision/scheduler/plateau_lr.py
Outdated
| param_group['lr'] = self.restore_lr[i] | ||
| self.restore_lr = None | ||
|
|
||
| self.lr_scheduler.step(metric, epoch) # step the base scheduler |
Contributor
Author
There was a problem hiding this comment.
flow.optim.lr_scheduler.ReduceLROnPlateau的step函数超参上缺少了一个epoch参数,可以对齐一下torch里的这个传参
Collaborator
There was a problem hiding this comment.
oeneflow 仓库的 ReduceLROnPlateau 也要改一下,还是先改了 这个再加吧,不然会报错
Contributor
Author
Draw LRScheduler Picture# from timm.scheduler.cosine_lr import CosineLRScheduler
from oneflow import optim
from flowvision.scheduler import MultiStepLRScheduler
from flowvision.models import ModelCreator
import oneflow as flow
model = ModelCreator.create_model("alexnet")
optimizer = flow.optim.SGD(model.parameters())
from matplotlib import pyplot as plt
from typing import List
a = [30, 60, 90]
print([_ * 100 for _ in a])
print(isinstance(a, list))
def get_lr_per_epoch(scheduler, num_epoch):
lr_per_epoch = []
for epoch in range(num_epoch):
lr_per_epoch.append(scheduler.get_epoch_values(epoch))
return lr_per_epoch
num_epoch = 100
scheduler = MultiStepLRScheduler(optimizer, decay_t=[30, 60, 90], decay_rate=0.1, warmup_lr_init=0.00001, warmup_t=10)
lr_per_epoch = []
for i in range(num_epoch):
scheduler.step(i)
lr_per_epoch.append(optimizer.param_groups[0]["lr"])
plt.plot([i for i in range(num_epoch)], lr_per_epoch)
plt.savefig("./test_multi_step.jpg") |
Ldpe2G
approved these changes
Jan 22, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TODO
Add more scheduler
PlateauLRScheduler ( ReduceLROnPlateau 传参 need to fix )OneFlow
ReduceLROnPlateaudidn't haveepochargs