mindspore/docs/api/api_python/nn/mindspore.nn.MultiClassDice...

26 lines
1.8 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.nn.MultiClassDiceLoss
================================
.. py:class:: mindspore.nn.MultiClassDiceLoss(weights=None, ignore_indiex=None, activation='softmax')
对于多标签问题可以将标签通过one-hot编码转换为多个二分类标签。每个通道可以看做是一个二分类问题所以损失可以通过先计算每个类别的二分类的 :class:`mindspore.nn.DiceLoss` 损失,再计算各二分类损失的平均值得到。
参数:
- **weights** (Union[Tensor, None]) - Shape为 :math:`(num\_classes, dim)` 的Tensor。权重shape[0]应等于标签shape[1]。默认值None。
- **ignore_indiex** (Union[int, None]) - 指定需要忽略的类别序号如果为None计算所有类别的Dice Loss值。默认值None。
- **activation** (Union[str, Cell]) - 应用于全连接层输出的激活函数,如'ReLU'。取值范围:['softmax', 'logsoftmax', 'relu', 'relu6', 'tanh', 'Sigmoid']。默认值:'softmax'。
输入:
- **logits** (Tensor) - shape为 :math:`(N, C, *)` 的Tensor其中 :math:`*` 表示任意数量的附加维度。logits维度应大于1。数据类型必须为float16或float32。
- **labels** (Tensor) - shape为 :math:`(N, C, *)` 的Tensor`logits` 的shape相同。标签维度应大于1。数据类型必须为float16或float32。
输出:
Tensor输出为每个样本采样通过MultiClassDiceLoss函数计算所得。
异常:
- **ValueError** - `logits``labels` 的shape不同。
- **TypeError** - `logits``labels` 的类型不是Tensor。
- **ValueError** - `logits``labels` 的维度小于2。
- **ValueError** - `weights` 的shape[0]和 `labels` 的shape[1]不相等。
- **ValueError** - `weights` 是Tensor但其维度不是2。