mindspore2022/docs/api/api_python/nn/mindspore.nn.Loss.rst

39 lines
845 B
ReStructuredText
Raw Permalink 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.nn.Loss
=================
.. py:class:: mindspore.nn.Loss
计算loss的平均值。如果每 :math:`n` 次迭代调用一次 `update` 方法,则计算结果为:
.. math::
loss = \frac{\sum_{k=1}^{n}loss_k}{n}
.. py:method:: clear()
内部评估结果清零。
.. py:method:: eval()
计算loss的平均值。
**返回:**
Floatloss的平均值。
**异常:**
- **RuntimeError** - 样本总数为0。
.. py:method:: update(*inputs)
更新内部评估结果。
**参数:**
- **inputs** - 输入只包含一个元素且该元素为loss。loss的维度必须为0或1。
**异常:**
- **ValueError** - `inputs` 的长度不为1。
- **ValueError** - `inputs` 的维度不为0或1。