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
【Hackathon No.12】为paddle新增OneCycleLR优化调度器 #29
Conversation
PR 格式检查通过,你的PR 将接受Paddle 专家以及开源社区的review,请及时关注PR 动态 |
|
||
测试考虑的case如下: | ||
|
||
- 和pytorch结果的数值的一致性, `paddle.optimizer.lr.OneCycleLR`和`torch.optim.lr_scheduler.OneCycleLR` 在不同情况下`step`后的`learning_rate`是否一致; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和pytorch结果的数值的一致性需要自己本地验证,因为Paddle CI环境中并不支持pytorch,CI中需要numpy验证方案。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是我表达不够清晰,单测代码已使用numpy验证方案,文档已修改
- `paddle.optimizer.lr.OneCycleLR`与`numpy`结果的数值一致性 | ||
- 错误检查:`total_step`, `epochs`和`steps_per_epoch`都未指定时能正确抛出错误,并且其数值小于等于0时能正确抛出错误; | ||
- 错误检查:`anneal_strategy`不在指定范围时能正确抛出错误; | ||
- 错误检查:`pct_start`值不在[0,1]时能正确抛出错误; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要构造小型网络(或单层网络),验证在框架训练模式下,学习率变化是否符合预期。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你的PR有最新反馈,请及时修改。 |
|
||
## 命名与参数设计 | ||
|
||
API设计为`paddle.optimizer.lr.OneCycleLR(max_learning_rate, total_steps=None, epochs=None, steps_per_epoch=None, pct_start=0.3, anneal_strategy='cos', divide_factor=25., final_divide_factor=1e4, three_phase=False, last_epoch=-1, verbose=False)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要说明每个参数的功能作用、默认设置等
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
|
||
## API实现方案 | ||
|
||
由于Paddle的lr_scheduler调用方式与Pytorch区别较大,因此做了修改,修改如下: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pytorch的optimizer也是作为参数传给lr_scheduler的,作为python函数这点功能是一致的,所以下面两点修改是否有必要?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pytorch中optimizer作为参数传给lr_scheduler,因此能同时修改momentum,而paddle中则是将lr_scheduler的子类实例传到optimizer中,调用方式上Pytorch为lr_scheduler(optimizer)
,而paddle为optimizer(learning_rate=lr_scheduler)
,paddle中的lr_scheduler并不能直接获取到optimizer的参数,因此修改是有必要的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,那可以先这样吧
|
||
## API实现方案 | ||
|
||
由于Paddle的lr_scheduler调用方式与Pytorch区别较大,因此做了修改,修改如下: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,那可以先这样吧
为paddle新增OneCycleLR优化调度器