!14393 Solve the example problem in comments
From: @lijiaqi0612 Reviewed-by: @kisnwang,@zh_qh Signed-off-by: @zh_qh
This commit is contained in:
commit
dda9f548ee
|
|
@ -452,7 +452,7 @@ class DiceLoss(_Loss):
|
||||||
single_dice_coeff = (2 * intersection) / (unionset + self.smooth)
|
single_dice_coeff = (2 * intersection) / (unionset + self.smooth)
|
||||||
dice_loss = 1 - single_dice_coeff
|
dice_loss = 1 - single_dice_coeff
|
||||||
|
|
||||||
return dice_loss.mean()
|
return dice_loss
|
||||||
|
|
||||||
|
|
||||||
@constexpr
|
@constexpr
|
||||||
|
|
@ -1078,7 +1078,7 @@ class FocalLoss(_Loss):
|
||||||
>>> focalloss = nn.FocalLoss(weight=Tensor([1, 2]), gamma=2.0, reduction='mean')
|
>>> focalloss = nn.FocalLoss(weight=Tensor([1, 2]), gamma=2.0, reduction='mean')
|
||||||
>>> output = focalloss(predict, target)
|
>>> output = focalloss(predict, target)
|
||||||
>>> print(output)
|
>>> print(output)
|
||||||
1.6610543
|
0.12516622
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, weight=None, gamma=2.0, reduction='mean'):
|
def __init__(self, weight=None, gamma=2.0, reduction='mean'):
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class BleuScore(Metric):
|
||||||
>>> metric.clear()
|
>>> metric.clear()
|
||||||
>>> metric.update(candidate_corpus, reference_corpus)
|
>>> metric.update(candidate_corpus, reference_corpus)
|
||||||
>>> bleu_score = metric.eval()
|
>>> bleu_score = metric.eval()
|
||||||
>>> print(output)
|
>>> print(bleu_score)
|
||||||
0.5946035575013605
|
0.5946035575013605
|
||||||
"""
|
"""
|
||||||
def __init__(self, n_gram=4, smooth=False):
|
def __init__(self, n_gram=4, smooth=False):
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ class ConfusionMatrixMetric(Metric):
|
||||||
>>> y = Tensor(np.array([[[0], [1]], [[1], [0]]]))
|
>>> y = Tensor(np.array([[[0], [1]], [[1], [0]]]))
|
||||||
>>> avg_output = metric.eval()
|
>>> avg_output = metric.eval()
|
||||||
>>> print(avg_output)
|
>>> print(avg_output)
|
||||||
[0.75]
|
[0.5]
|
||||||
"""
|
"""
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
skip_channel=True,
|
skip_channel=True,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue