From 209b2f1e042fcc9951b086fed9d3e895d995d8ea Mon Sep 17 00:00:00 2001 From: chenhaozhe Date: Mon, 16 Aug 2021 11:01:38 +0800 Subject: [PATCH] fix comments for LossBase.get_loss --- mindspore/nn/loss/loss.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mindspore/nn/loss/loss.py b/mindspore/nn/loss/loss.py index bbf0adfe61f..7bc395019e7 100644 --- a/mindspore/nn/loss/loss.py +++ b/mindspore/nn/loss/loss.py @@ -76,8 +76,8 @@ class LossBase(Cell): Args: weights (Union[float, Tensor]): Optional `Tensor` whose rank is either 0, or the same rank as inputs, - and must be broadcastable to inputs (i.e., all dimensions must be either `1`, - or the same as the corresponding inputs dimension). + and must be broadcastable to inputs (i.e., all dimensions must be either `1`, + or the same as the corresponding inputs dimension). """ input_dtype = x.dtype x = self.cast(x, mstype.float32) @@ -1282,10 +1282,10 @@ class FocalLoss(LossBase): convert_weight = self.squeeze(convert_weight) log_probability = log_probability * convert_weight - weight = F.pows(-probability + 1.0, self.gamma) + weight = F.pows(-1 * probability + 1.0, self.gamma) if target.shape[1] == 1: - loss = (-weight * log_probability).mean(axis=1) + loss = (-1 * weight * log_probability).mean(axis=1) else: - loss = (-weight * targets * log_probability).mean(axis=-1) + loss = (-1 * weight * targets * log_probability).mean(axis=-1) return self.get_loss(loss)