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 4 No.16】为 Paddle 新增 PoissonNLLLoss API #395

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

LyndonKong
Copy link
Contributor

Add PoissonNLLLoss API rfc file

@paddle-bot
Copy link

paddle-bot bot commented Mar 1, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请检查PR提交格式和内容是否完备,具体请参考示例模版
Your PR has been submitted. Thanks for your contribution!
Please check its format and content. For this, you can refer to Template and Demo.


# 四、对比分析

设计方案将参考PyTorch的实现,在当前版本的API当中仅实现Python版本,对于PyTorch实现中部分抛弃的参数不再做兼容。
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.

更新在了第四部分中


## 1、相关背景

paddle.nn.PoissonNLLLoss 和 paddle.nn.functional.Poisson_nll_loss API 用于泊松分布的负对数似然函数的计算。
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的描述

\text{loss}(\text{input}, \text{target}) = \text{input} - \text{target} * \log(\text{input}) + \log(\text{target!})
$$

损失函数中的最后一项可以使用Stirling公式近似,当target的值超过1时考虑此项近似,当target的值小于等于1的时候设置为0。
Copy link
Contributor

Choose a reason for hiding this comment

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

大于1和小于1怎么定义?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里是和每一个元素都是1的Tensor进行elemen-wise的比较,小于等于1的地方mask掉对应的逼近项。在PyTorch的实现中调用的是Tensor.masked_fill(mask, value)。

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.

在设计文档和中文文档中补充了这个说明。

Copy link
Contributor

@GGBond8488 GGBond8488 left a comment

Choose a reason for hiding this comment

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

LGTM

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

4 participants