-
Notifications
You must be signed in to change notification settings - Fork 876
[API Compatibility]fix the loss doc #7632
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
base: develop
Are you sure you want to change the base?
Conversation
|
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7632.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
📚 本次 PR 文档预览链接(点击展开)
|
|
@zhwesky2010 您有空了看看这个格式是否可行,这里CI报错但是报错文档打不开,实在不知道为什么有问题 |
| # PyTorch 写法 | ||
| torch.nn.BCELoss(size_average=True) | ||
| torch.nn.BCELoss(weight=w, size_average=False, reduce=True) | ||
| torch.nn.BCELoss(weight=w, size_average=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.
还有一种写法
torch.nn.BCELoss(weight=w, reduction='sum)
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.
这里我看不是之前都只给size_average+reduce到reduction的转写示例嘛,reduction到reduction是一一对应的关系,还要写出来吗
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 写法 | ||
| paddle.nn.BCELoss(reduction='mean') | ||
| paddle.nn.BCELoss(weight=w, reduction='sum') |
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.
注释一下:
## 以上写法都统一对应到如下写法
|
|
||
| #### size_average | ||
| size_average 为 True | ||
| #### reduction 为 sum |
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.
一共有34种用法,还有torch.nn.functional.* 下面有17个
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.
这个路径下的loss,我看paddle都没支持size_average,reduce参数,要支持一下吗
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.
这个路径下的loss,我看paddle都没支持size_average,reduce参数,要支持一下吗
需要支持。同时之前的的legacy_reduction_decorator也需要在loss.py的functional API里都支持下。
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.
由于loss.py下都是函数(之前的17个loss是类),所以需要在原来的legacy_reduction_decorator里新增一个判断,因为原来算位置参数需要跳过self,如果是函数的话就不用跳过,会引入新的开销;或者就再写一个装饰器,不过大部分代码都可以复用,您看哪个好一点
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.
由于loss.py下都是函数(之前的17个loss是类),所以需要在原来的legacy_reduction_decorator里新增一个判断,因为原来算位置参数需要跳过self,如果是函数的话就不用跳过,会引入新的开销;或者就再写一个装饰器,不过大部分代码都可以复用,您看哪个好一点
@zhwesky2010 您有空了看一下这个哈
|
好,那我先对这些api做支持,再来改文档吧
---- Replied Message ----
| From | ***@***.***> |
| Date | 11/18/2025 16:17 |
| To | PaddlePaddle/docs ***@***.***> |
| Cc | Tianyu ***@***.***>,
Author ***@***.***> |
| Subject | Re: [PaddlePaddle/docs] [API Compatibility]fix the loss doc (PR #7632) |
@zhwesky2010 commented on this pull request.
In docs/guides/model_convert/convert_from_pytorch/api_difference/torch_more_args/torch.nn.BCELoss.md:
@@ -25,65 +25,35 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下:
| reduction | reduction | 表示应用于输出结果的计算方式。 |
### 转写示例
-
-
-#### size_average
-size_average 为 True
+#### reduction 为 sum
这个路径下的loss,我看paddle都没支持size_average,reduce参数,要支持一下吗
需要支持。paddle都不支持size_average、reduce参数吧
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
17种存在size_average与reduce的loss,添加size_average+reduce->reduction的转写示例