mindspore/docs/api/api_python/ops/mindspore.ops.SmoothL1Loss.rst

44 lines
1.6 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.SmoothL1Loss
==========================
.. py:class:: mindspore.ops.SmoothL1Loss(beta=1.0)
计算平滑L1损失该L1损失函数有稳健性。
平滑L1损失是一种类似于MSELoss的损失函数但对异常值相对不敏感。参阅论文 `Fast R-CNN <https://arxiv.org/abs/1504.08083>`_
给定长度为 :math:`N` 的两个输入 `x``y` 平滑L1损失的计算如下
.. math::
L_{i} =
\begin{cases}
\frac{0.5 (x_i - y_i)^{2}}{\beta}, & \text{if } |x_i - y_i| < \beta \\
|x_i - y_i| - 0.5 * \beta, & \text{otherwise. }
\end{cases}
其中, :math:`\beta` 代表阈值 `beta`:math:`N` 为batch size。
.. warning::
此运算符不对损失值执行"reduce"操作。
如果需要请调用其他reduce运算符对损失执行"reduce"操作。
**参数:**
- **beta** (float) - 控制损失函数在L1Loss和L2Loss间变换的阈值。默认值1.0。
**输入:**
- **logits** (Tensor) - shape :math:`(N, *)` ,其中 :math:`*` 表示任意数量的附加维度。数据类型支持float16或float32。
- **labels** (Tensor) - shape :math:`(N, *)` ,与 `logits` 的shape和数据类型相同。
**输出:**
Tensor损失值`logits` 的shape和数据类型相同。
**异常:**
- **TypeError** - `beta` 不是float类型。
- **TypeError** - `logits``labels` 的数据类型非float16或float32。
- **ValueError** - `beta` 小于或等于0。
- **ValueError** - `logits``labels` 的shape不同。