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

【Hackathon No.12】为paddle新增OneCycleLR优化调度器 #29

Merged
merged 6 commits into from Mar 29, 2022
Merged

【Hackathon No.12】为paddle新增OneCycleLR优化调度器 #29

merged 6 commits into from Mar 29, 2022

Conversation

Asthestarsfalll
Copy link
Contributor

为paddle新增OneCycleLR优化调度器

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

@dingjiaweiww
Copy link
Contributor

你的 PR 提交成功,感谢你对于开源项目的贡献,请检查 PR 提交格式和内容是否完备,具体请参考示例模版

@dingjiaweiww
Copy link
Contributor

PR 格式检查通过,你的PR 将接受Paddle 专家以及开源社区的review,请及时关注PR 动态


测试考虑的case如下:

- 和pytorch结果的数值的一致性, `paddle.optimizer.lr.OneCycleLR`和`torch.optim.lr_scheduler.OneCycleLR` 在不同情况下`step`后的`learning_rate`是否一致;
Copy link
Contributor

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验证方案。

Copy link
Contributor Author

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]时能正确抛出错误;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要构造小型网络(或单层网络),验证在框架训练模式下,学习率变化是否符合预期。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在本地进行了测试,但是不清楚如何表述才更加清晰

7W4UI0813U~@QN9G99`K %F

D6@ Y 9H`K204 {_U~)Z4Y9

@paddle-bot-old
Copy link

你的PR有最新反馈,请及时修改。
There’s the latest feedback about your PR. Please check.

@Asthestarsfalll Asthestarsfalll changed the title 【Hackathon No.12】 【Hackathon No.12】为paddle新增OneCycleLR优化调度器 Mar 19, 2022
DDDivano
DDDivano previously approved these changes Mar 24, 2022

## 命名与参数设计

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)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要说明每个参数的功能作用、默认设置等

Copy link
Contributor Author

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区别较大,因此做了修改,修改如下:
Copy link
Contributor

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函数这点功能是一致的,所以下面两点修改是否有必要?

Copy link
Contributor Author

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的参数,因此修改是有必要的。

Copy link
Contributor

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区别较大,因此做了修改,修改如下:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,那可以先这样吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants