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

45 lines
1.3 KiB
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.Dice
==================
.. py:class:: mindspore.nn.Dice(smooth=1e-5)
集合相似性度量。
用于计算两个样本之间的相似性。当分割结果最好时Dice系数的值为1当分割结果最差时Dice系数的值为0。Dice系数表示预测值与真实值交集同预测值和真实值并集之间的比值。
.. math::
dice = \frac{2 * (pred \bigcap true)}{pred \bigcup true}
**参数:**
- **smooth** (float) - 在计算过程中添加到分母里用于提高数值稳定性取值需大于0。默认值1e-5。
.. py:method:: clear()
重置评估结果。
.. py:method:: eval()
计算Dice系数。
**返回:**
Float计算的结果。
**异常:**
- **RuntimeError** - 样本数为0。
.. py:method:: update(*inputs)
更新内部评估结果 `y_pred``y`
**参数:**
- **inputs** (tuple) -输入 `y_pred``y``y_pred``y` 是tensor、列表或numpy.ndarray。 `y_pred` 是预测值, `y` 是真实值。
**异常:**
- **ValueError** - 输入参数的数量不等于2。
- **ValueError** - 如果预测值和标签shape不一致。