You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.SoftMarginLoss.rst 1.2 kB

123456789101112131415161718192021222324252627282930313233
  1. mindspore.nn.SoftMarginLoss
  2. ============================
  3. .. py:class:: mindspore.nn.SoftMarginLoss(reduction='mean')
  4. 针对二分类问题的损失函数。
  5. SoftMarginLoss用于计算输入Tensor :math:`x` 和目标值Tensor :math:`y` (包含1或-1)的二分类损失值。
  6. .. math::
  7. \text{loss}(x, y) = \sum_i \frac{\log(1 + \exp(-y[i]*x[i]))}{\text{x.nelement}()}
  8. :math:`x.nelement()` 代表 `x` 中元素的个数。
  9. **参数:**
  10. - **reduction** (str) - 指定应用于输出结果的计算方式。取值为"mean","sum",或"none"。默认值:"mean"。
  11. **输入:**
  12. - **logits** (Tensor) - 预测值,数据类型为float16或float32。
  13. - **labels** (Tensor) - 目标值,数据类型和shape与 `logits` 的相同。
  14. **输出:**
  15. Tensor或Scalar,如果 `reduction` 为"none",其shape与 `logits` 相同。否则,将返回Scalar。
  16. **异常:**
  17. - **TypeError** - `logits` 或 `labels` 不是Tensor。
  18. - **TypeError** - `logits` 或 `labels` 的数据类型既不是float16也不是float32。
  19. - **ValueError** - `logits` 的shape与 `labels` 不同。
  20. - **ValueError** - `reduction` 不为"mean","sum",或"none"。