-
Notifications
You must be signed in to change notification settings - Fork 824
补充GaussianNLLLoss中文文档。;test=docs_preview #5623
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
Changes from 6 commits
1488c59
5949db9
88cfd19
6ed290b
221f9bd
ed41652
996c173
811c9cf
0b9b5b4
75b8934
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.. _cn_api_paddle_nn_GaussianNLLLoss: | ||
|
||
GaussianNLLLoss | ||
------------------------------- | ||
|
||
.. py:class:: paddle.nn.GaussianNLLLoss(full=False, epsilon=1e-6, reduction='mean', name=None) | ||
|
||
计算输入 :attr:`input` 和标签 :attr:`label`、 :attr:`variance` 间的 GaussianNLL 损失, | ||
:attr:`label` 被视为高斯分布的样本,其期望和方差由神经网络预测给出。对于一个 :attr:`label` 张量建模为具有高斯分布的张量的期望值 :attr:`input` 和张量的正方差 :attr:`var`,数学计算公式如下: | ||
|
||
.. math:: | ||
\text{loss} = \frac{1}{2}\left(\log\left(\text{max}\left(\text{var}, | ||
\ \text{epsilon}\right)\right) + \frac{\left(\text{input} - \text{label}\right)^2} | ||
{\text{max}\left(\text{var}, \ \text{epsilon}\right)}\right) + \text{const.} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
参数 | ||
:::::::::: | ||
|
||
- **full** (bool,可选) - 是否在损失计算中包括常数项。默认情况下为 False,表示忽略最后的常数项。 | ||
- **epsilon** (float,可选) - 用于限制 variance 的值,使其不会导致除 0 的出现。默认值为 1e-6。 | ||
- **reduction** (str,可选) - 指定应用于输出结果的计算方式,可选值有 ``none``、``mean`` 和 ``sum``。默认为 ``mean``,计算 ``mini-batch`` loss 均值。设置为 ``sum`` 时,计算 ``mini-batch`` loss 的总和。设置为 ``none`` 时,则返回 loss Tensor。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 | ||
|
||
形状 | ||
:::::::::: | ||
|
||
- **input** (Tensor):输入 :attr:`Tensor`,其形状为 :math:`(N, *)` 或者 :math:`(*)`,其中 :math:`*` 表示任何数量的额外维度。数据类型为 float32 或 float64。 | ||
- **label** (Tensor):输入 :attr:`Tensor`,其形状为 :math:`(N, *)` 或者 :math:`(*)`,形状与 :attr:`input` 相同,或者其中一维的大小为 1,这时会进行 broadcast 操作。数据类型为 float32 或 float64。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “或者”后面的建议描述再清楚些,如 或者形状与input相同但.... |
||
- **variance** (Tensor): 输入 :attr:`Tensor`,其形状为 :math:`(N, *)` 或者 :math:`(*)`,形状与 :attr:`input` 相同,或其中一维的大小为 1,或缺少一维,这时会进行 broadcast 操作。数据类型为 float32 或 float64。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
返回 | ||
::::::::: | ||
|
||
Tensor,计算 `GaussianNLLLoss` 后的损失值。若 :attr:`reduction` 为 ``none``,则与输入形状相同。 | ||
|
||
|
||
代码示例 | ||
::::::::: | ||
|
||
COPY-FROM: paddle.nn.GaussianNLLLoss |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. _cn_api_nn_functional_gaussian_nll_loss: | ||
|
||
gaussian_nll_loss | ||
------------------------------- | ||
.. py:function:: paddle.nn.functional.gaussian_nll_loss(input, label, variance, full=False, epsilon=1e-6, reduction='mean', name=None) | ||
|
||
返回 `gaussian negative log likelihood loss`。可在 :ref:`cn_api_paddle_nn_GaussianNLLLoss` 查看详情。 | ||
|
||
参数 | ||
::::::::: | ||
- **input** (Tensor):输入 :attr:`Tensor`,其形状为 :math:`(N, *)` 或者 :math:`(*)`,其中 :math:`*` 表示任何数量的额外维度。将被拟合成为高斯分布。数据类型为 float32 或 float64。 | ||
- **label** (Tensor):输入 :attr:`Tensor`,其形状为 :math:`(N, *)` 或者 :math:`(*)`,形状、数据类型和 :attr:`input` 相同,或者其中一维的大小为 1,这时会进行 broadcast 操作。为服从高斯分布的样本。数据类型为 float32 或 float64。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同样的,按上述要求对“或者”后的描述更清晰化一些 |
||
- **variance** (Tensor): 输入 :attr:`Tensor`,其形状为 :math:`(N, *)` 或者 :math:`(*)`,形状与 :attr:`input` 相同,或其中一维的大小为 1,或缺少一维,这时会进行 broadcast 操作。正方差样本,可为不同标签对应不同的方差(异方差性),也可以为同一个方差(同方差性)。数据类型为 float32 或 float64。 | ||
- **full** (bool,可选) - 是否在损失计算中包括常数项。默认情况下为 False,表示忽略最后的常数项。 | ||
- **epsilon** (float,可选) - 用于限制 variance 的值,使其不会导致除 0 的出现。默认值为 1e-6。 | ||
- **reduction** (str,可选) - 指定应用于输出结果的计算方式,可选值有 ``none``、``mean`` 和 ``sum``。默认为 ``mean``,计算 ``mini-batch`` loss 均值。设置为 `sum` 时,计算 `mini-batch` loss 的总和。设置为 ``none`` 时,则返回 loss Tensor。 | ||
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 | ||
|
||
返回 | ||
::::::::: | ||
`Tensor`,返回存储表示 `gaussian negative log likelihood loss` 的损失值。数据类型与:attr:`input`相同。当 reduction 为:attr:`none`时,形状与:attr:`input`相同。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
代码示例 | ||
::::::::: | ||
|
||
COPY-FROM: paddle.nn.functional.gaussian_nll_loss |
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.
总感觉这段话读起来不太通顺..尤其是最后一句
对于一个 label 张量建模为具有高斯分布的张量的期望值 input 和张量的正方差 var
,建议从头开始的整段描述再斟酌、优化一下