-
Notifications
You must be signed in to change notification settings - Fork 758
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.21 #4723
Merged
Merged
Hackathon No.21 #4723
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8d39f1a
Create soft_margin_loss_cn.rst
yangguohao 2752f2a
Create SoftMarginLoss_cn.rst
yangguohao e53d56a
Update SoftMarginLoss_cn.rst
yangguohao 56555e7
Update soft_margin_loss_cn.rst
yangguohao 305fa14
Update SoftMarginLoss_cn.rst
yangguohao e5c0ec6
Update Overview_cn.rst
yangguohao 5b11bd2
Update soft_margin_loss_cn.rst
yangguohao 61911a8
Update soft_margin_loss_cn.rst
yangguohao 7466d58
Merge branch 'develop' into SoftMarginLoss
Ligoml 0a39273
Update SoftMarginLoss_cn.rst
Ligoml b1effd1
Update soft_margin_loss_cn.rst
Ligoml File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.. _cn_api_paddle_nn_SoftMarginloss: | ||
|
||
SoftMarginloss | ||
------------------------------- | ||
|
||
.. py:class:: paddle.nn.SoftMarginloss((reduction='mean', name=None) | ||
|
||
生成一个可以计算输入 `input` 和 `label` 间的二分类损失的类。 | ||
|
||
|
||
损失函数按照下列公式计算 | ||
|
||
.. math:: | ||
\text{loss}(x, y) = \sum_i \frac{\log(1 + \exp(-y[i]*x[i]))}{\text{x.nelement}()} | ||
|
||
|
||
最后,添加 `reduce` 操作到前面的输出Out上。当 `reduction` 为 `none` 时,直接返回最原始的 `Out` 结果。当 `reduction` 为 `mean` 时,返回输出的均值 :math:`Out = MEAN(Out)` 。当 `reduction` 为 `sum` 时,返回输出的求和 :math:`Out = SUM(Out)` 。 | ||
|
||
|
||
参数 | ||
::::::::: | ||
- **reduction** (str,可选) - 指定应用于输出结果的计算方式,可选值有: ``'none'``, ``'mean'``, ``'sum'`` 。默认为 ``'mean'``,计算 Loss 的均值;设置为 ``'sum'`` 时,计算 Loss 的总和;设置为 ``'none'`` 时,则返回原始Loss。 | ||
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。 | ||
|
||
形状 | ||
::::::::: | ||
- **input** (Tensor) - :math:`[N, *]` , 其中N是batch_size, `*` 是任意其他维度。数据类型是float32、float64。 | ||
- **label** (Tensor) - :math:`[N, *]` ,标签 ``label`` 的维度、数据类型与输入 ``input`` 相同。 | ||
- **output** (Tensor) - 输出的Tensor。如果 :attr:`reduction` 是 ``'none'``,则输出的维度为 :math:`[N, *]`,与输入 ``input`` 的形状相同。如果 :attr:`reduction` 是 ``'mean'`` 或 ``'sum'``,则输出的维度为 :math:`[1]` 。 | ||
|
||
返回 | ||
::::::::: | ||
返回计算SoftMarginLoss的可调用对象。 | ||
|
||
|
||
代码示例 | ||
::::::::: | ||
COPY-FROM: paddle.nn.SoftMarginLoss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.. _cn_api_paddle_nn_functional_soft_margin_losss: | ||
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. 多了个 s |
||
|
||
soft_margin_loss | ||
------------------------------- | ||
|
||
.. py:function:: paddle.nn.functional.soft_margin_loss(input, label, weight:Optional=None, reduction: str = 'mean') | ||
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. 没有 weight 参数吧 |
||
|
||
计算输入 `input` 和 `label` 间的二分类损失。 | ||
|
||
|
||
损失函数按照下列公式计算 | ||
|
||
.. math:: | ||
\text{loss}(x, y) = \sum_i \frac{\log(1 + \exp(-y[i]*x[i]))}{\text{x.nelement}()} | ||
|
||
|
||
最后,添加 `reduce` 操作到前面的输出Out上。当 `reduction` 为 `none` 时,直接返回最原始的 `Out` 结果。当 `reduction` 为 `mean` 时,返回输出的均值 :math:`Out = MEAN(Out)` 。当 `reduction` 为 `sum` 时,返回输出的求和 :math:`Out = SUM(Out)` 。 | ||
|
||
|
||
参数 | ||
::::::::: | ||
- **input** (Tensor) - :math:`[N, *]` ,其中N是batch_size, `*` 是任意其他维度。数据类型是float32、float64。 | ||
- **label** (Tensor) - :math:`[N, *]` ,标签 ``label`` 的维度、数据类型与输入 ``input`` 相同。 | ||
- **weight** (Tensor,可选) - 手动指定每个batch二值交叉熵的权重,如果指定的话,维度必须是一个batch的数据的维度。数据类型是float32, float64。默认值是:None。 | ||
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. 同 |
||
- **reduction** (str,可选) - 指定应用于输出结果的计算方式,可选值有: ``'none'``, ``'mean'``, ``'sum'`` 。默认为 ``'mean'``,计算 Loss 的均值;设置为 ``'sum'`` 时,计算 Loss 的总和;设置为 ``'none'`` 时,则返回原始 Loss。 | ||
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。 | ||
|
||
|
||
返回 | ||
::::::::: | ||
- 输出的结果Tensor。如果 :attr:`reduction` 是 ``'none'``, 则输出的维度为 :math:`[N, *]` , 与输入 ``input`` 的形状相同。如果 :attr:`reduction` 是 ``'mean'`` 或 ``'sum'``, 则输出的维度为 :math:`[1]` 。 | ||
|
||
|
||
代码示例 | ||
::::::::: | ||
COPY-FROM: paddle.nn.functional.soft_margin_loss |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
这一段英文没有,建议补充一下