-
Notifications
You must be signed in to change notification settings - Fork 749
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.30 #4644
Hackathon No.30 #4644
Conversation
Thanks for your contribution! |
docs/api/paddle/nn/Overview_cn.rst
Outdated
@@ -256,6 +256,7 @@ Loss层 | |||
" :ref:`paddle.nn.MSELoss <cn_api_paddle_nn_MSELoss>` ", "均方差误差损失层" | |||
" :ref:`paddle.nn.NLLLoss <cn_api_nn_loss_NLLLoss>` ", "NLLLoss层" | |||
" :ref:`paddle.nn.SmoothL1Loss <cn_api_paddle_nn_SmoothL1Loss>` ", "平滑L1损失层" | |||
" :ref:`paddle.nn.TripletMarginWithDistanceLoss <cn_api_paddle_nn_TripletMarginWithDistanceLoss>` TripletMarginWithDistanceLoss层" |
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.
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.
已修改
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.
已修改
docs/api/paddle/nn/Overview_cn.rst
Outdated
@@ -473,6 +474,7 @@ Embedding相关函数 | |||
" :ref:`paddle.nn.functional.smooth_l1_loss <cn_paddle_nn_functional_loss_smooth_l1>` ", "用于计算平滑L1损失" | |||
" :ref:`paddle.nn.functional.softmax_with_cross_entropy <cn_api_fluid_layers_softmax_with_cross_entropy>` ", "将softmax操作、交叉熵损失函数的计算过程进行合并" | |||
" :ref:`paddle.nn.functional.margin_cross_entropy <cn_api_paddle_nn_functional_margin_cross_entropy>` ", "支持 ``Arcface``,``Cosface``,``Sphereface`` 的结合 Margin 损失函数" | |||
" :ref:`paddle.nn.functional.triplet_margin_with_distance_loss <cn_paddle_nn_functional_triplet_margin_with_distance_loss>` ", "用户自定义距离函数用于计算triplet margin 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.
这里是不是缺少了nn.functional.triplet_margin_with_distance_loss的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.
已添加
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.
已添加
|
||
.. py:class:: paddle.nn.TripletMarginWithDistanceLoss(margin: float = 1.0, swap: bool = False, reduction: str = 'mean') | ||
|
||
该OP可创建一个TripletMarginWithDistanceLoss的可调用类,计算输入 `input` 和 `positive` 和 `negative` 间的 `triplet margin 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.
去掉「该OP」的说法
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.
done
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.
done
- **swap** (bool,可选) | ||
- **margin** (float,可选) - 手动指定间距,默认为1 | ||
- **reduction**(str,可选) -指定应用于输出结果的计算方式,可选值有: ``'none'``, ``'mean'``, ``'sum'`` 。默认为 ``'mean'``,计算 Loss 的均值;设置为 ``'sum'`` 时,计算 Loss 的总和;设置为 ``'none'`` 时,则返回原始Loss。 | ||
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。 |
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.
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.
done
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.
done
代码示例 | ||
::::::::: | ||
|
||
.. code-block:: python |
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.
代码建议使用copy-from的方式,参考文档
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.
done
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.
done
d(x_i, y_i) = \left\lVert {\bf x}_i - {\bf y}_i \right\rVert_2 | ||
|
||
|
||
其中 ``distance_function`` 为距离函数,默认为2范数。 ``margin`` 为(input,positive)与(input,negative)的距离间隔, ``swap`` 的内容可以看论文 `Learning shallow convolutional feature descriptors with triplet losses <http://www.bmva.org/bmvc/2016/papers/paper119/paper119.pdf>`_。 |
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.
swap
的内容可以看论文 --> swap
xxxx,详见论文(xxxx里简单描述一下这个参数吧)
- **swap** (bool,可选) - 默认为False | ||
- **margin** (float,可选) - 手动指定间距,默认为1。 | ||
- **reduction** (str,可选) - 指定应用于输出结果的计算方式,可选值有: ``'none'``, ``'mean'``, ``'sum'`` 。默认为 ``'mean'``,计算 Loss 的均值;设置为 ``'sum'`` 时,计算 Loss 的总和;设置为 ``'none'`` 时,则返回原始Loss。 | ||
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。 |
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.
- 参数需在括号里写清数据类型和是否可选,可选参数需要注明默认值
,
-->,
,句尾加。
- 参数要和源码顺序保持一致
- 没有name参数就不要写
- 中英文字符之间最好使用一个空格隔开
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.
已修改
|
||
.. py:class:: paddle.nn.functional.triplet_margin_with_distance_loss(input, positive, negative, distance_function=None, margin: float = 1.0, swap: bool = False, reduction: str = 'mean') | ||
|
||
该api计算输入 `input` 和 `positive` 和 `negative` 间的 `triplet margin 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.
去掉「该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.
已修改
triplet_margin_with_distance_loss | ||
------------------------------- | ||
|
||
.. py:class:: paddle.nn.functional.triplet_margin_with_distance_loss(input, positive, negative, distance_function=None, margin: float = 1.0, swap: bool = False, reduction: str = 'mean') |
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.
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.
已修改
|
||
|
||
参数 | ||
::::::::: |
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.
参考TripletMarginWithDistanceLoss进行修改
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.
已修改
- **distance_function** (可选) - 手动指定范数,默认为None, 使用欧式距离。 | ||
- **margin** (float,可选) - 手动指定间距,默认为1。 | ||
- **swap** (bool,可选) - 默认为False。 | ||
- **reduction** (str,可选) - 指定应用于输出结果的计算方式,可选值有: ``'none'``, ``'mean'``, ``'sum'`` 。默认为 ``'mean'``,计算 Loss 的均值;设置为 ``'sum'`` 时,计算 Loss 的总和;设置为 ``'none'`` 时,则返回原始 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.
,
--> ,
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.
已修改
|
||
参数 | ||
::::::::: | ||
- **distance_function** (可选) - 手动指定范数,默认为None, 使用欧式距离。 |
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.
- 参数的数据类型需要增加
,
-->,
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.
LGTM
TripletMarginLoss API 中文文档
PADDLEPADDLE_PR=40545
【Hackathon No.30】PaddlePaddle/Paddle#40545