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

12345678910111213141516171819202122232425262728293031
  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. **参数:**
  9. - **reduction** (str) - 指定应用于输出结果的计算方式。取值为"mean","sum",或"none"。默认值:"mean"。
  10. **输入:**
  11. - **logits** (Tensor) - 预测值,数据类型为float16或float32。
  12. - **labels** (Tensor) - 目标值,数据类型和shape与 `logits` 的相同。
  13. **输出:**
  14. Tensor或Scalar,如果 `reduction` 为"none",其shape与 `logits` 相同。否则,将返回scalar。
  15. **异常:**
  16. - **TypeError** - `logits` 或 `labels` 不是Tensor。
  17. - **TypeError** - `logits` 或 `labels` 的数据类型既不是float16也不是float32。
  18. - **ValueError** - `logits` 的shape与 `labels` 不同。
  19. - **ValueError** - `reduction` 不为"mean","sum",或"none"。