-
Notifications
You must be signed in to change notification settings - Fork 674
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 6th No. 27】为 paddle.io.RandomSampler/random_split /Layer.clear_gradients 进行功能增强 #6594
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-6594.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
* add backednds.cudnn.version * add celu * add torch.distributed.ReduceOp * update some docs * update some docs of PaddlePaddle#6594 * update some docs
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
PyTorch 的 `Module.zero_grad` 参数与 Paddle 的 `Layer.clear_gradients` 参数用法不同,具体如下: |
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.
已修改
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ----------- | ------------ | ------------------------------------------------ | | ||
| set_to_none | - | 是否设置为 None,Paddle 无此参数,暂无转写方式。 | | ||
| set_to_none | set_to_zero | 设置如何清空梯度,PyTorch 默认设置为 None,Paddle 默认设置为 0,需要转写。 | |
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.
Pytoch直接写None的表现吧,None就是设为True的意思吧
两者功能刚好相反,Paddle需设置为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.
好的,已修改
@@ -9,13 +9,23 @@ torch.nn.Module.zero_grad(set_to_none=True) | |||
### [paddle.nn.Layer.clear_gradients](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/Layer_cn.html#clear-gradients) | |||
|
|||
```python | |||
paddle.nn.Layer.clear_gradients() | |||
paddle.nn.Layer.clear_gradients(set_to_zero=True) |
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.
后面再给 paddle.nn.Layer.clear_gradients
加一个别名 paddle.nn.Layer.clear_grad
吧,这样可以和 paddle.optim.Optimizer.clear_grad
完全对应上
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.
LGTM
refer to:
PaddlePaddle/Paddle#62966