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.17】RFC #144

Merged
merged 3 commits into from
May 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions rfcs/APIs/20220319_api_design_for_CosineEmbeddingLoss.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,13 @@ def cosine_similarity(y_true, y_pred, axis=-1):

## 命名与参数设计

CosineEmbeddingLoss的API设计为`paddle.nn.CosineEmbeddingLoss(margin=0, reduction='mean')`,cosine_embedding_loss的API设计为`paddle.nn.functional.cosine_embedding_loss(x1, x2, target, margin=0, reduction='mean')`,其中:
CosineEmbeddingLoss的API设计为`paddle.nn.CosineEmbeddingLoss(margin=0, reduction='mean', name=None)`,cosine_embedding_loss的API设计为`paddle.nn.functional.cosine_embedding_loss(input1, input2, label, margin=0, reduction='mean', name=None)`,其中:

* margin:余弦相似度损失函数中的margin值
* reduction:结果后处理的类型,可以为`mean`或者`sum`
* x1和x2:输入的两个tensor
* target:真实的类别标签
* input1和input2:输入的两个tensor
* label:真实的类别标签
Copy link
Contributor

Choose a reason for hiding this comment

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

再加一行name的说明吧。另外下面的工作也需要同步做一下:

  • API添加name参数,注意也将name参数传入函数内部调用的部分其他API,细节可参考其他loss函数的实现
  • 中/英文文档补充name参数及对应说明

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

* name:操作的名称,更多信息请参见 [Name](https://www.paddlepaddle.org.cn/documentation/docs/zh/api_guides/low_level/program.html#api-guide-name)。

在pytorch中,CosineEmbeddingLoss还有`size_average`、`reduce`两个参数,但是已经弃用,其功能转移到`reduction`参数上。两个参数的描述文档如下

Expand Down