Browse Source

!14393 Solve the example problem in comments

From: @lijiaqi0612
Reviewed-by: @kisnwang,@zh_qh
Signed-off-by: @zh_qh
pull/14393/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
dda9f548ee
3 changed files with 4 additions and 4 deletions
  1. +2
    -2
      mindspore/nn/loss/loss.py
  2. +1
    -1
      mindspore/nn/metrics/bleu_score.py
  3. +1
    -1
      mindspore/nn/metrics/confusion_matrix.py

+ 2
- 2
mindspore/nn/loss/loss.py View File

@@ -452,7 +452,7 @@ class DiceLoss(_Loss):
single_dice_coeff = (2 * intersection) / (unionset + self.smooth)
dice_loss = 1 - single_dice_coeff

return dice_loss.mean()
return dice_loss


@constexpr
@@ -1078,7 +1078,7 @@ class FocalLoss(_Loss):
>>> focalloss = nn.FocalLoss(weight=Tensor([1, 2]), gamma=2.0, reduction='mean')
>>> output = focalloss(predict, target)
>>> print(output)
1.6610543
0.12516622
"""

def __init__(self, weight=None, gamma=2.0, reduction='mean'):


+ 1
- 1
mindspore/nn/metrics/bleu_score.py View File

@@ -38,7 +38,7 @@ class BleuScore(Metric):
>>> metric.clear()
>>> metric.update(candidate_corpus, reference_corpus)
>>> bleu_score = metric.eval()
>>> print(output)
>>> print(bleu_score)
0.5946035575013605
"""
def __init__(self, n_gram=4, smooth=False):


+ 1
- 1
mindspore/nn/metrics/confusion_matrix.py View File

@@ -182,7 +182,7 @@ class ConfusionMatrixMetric(Metric):
>>> y = Tensor(np.array([[[0], [1]], [[1], [0]]]))
>>> avg_output = metric.eval()
>>> print(avg_output)
[0.75]
[0.5]
"""
def __init__(self,
skip_channel=True,


Loading…
Cancel
Save