diff --git a/mindspore/nn/loss/loss.py b/mindspore/nn/loss/loss.py index 62014b0c330..348e909a1a6 100644 --- a/mindspore/nn/loss/loss.py +++ b/mindspore/nn/loss/loss.py @@ -908,7 +908,7 @@ class CosineEmbeddingLoss(_Loss): prod_sum = self.reduce_sum(x1 * x2, (1,)) square1 = self.reduce_sum(F.square(x1), (1,)) square2 = self.reduce_sum(F.square(x2), (1,)) - denom = F.sqrt(square1 * square2) + denom = F.sqrt(square1) * F.sqrt(square2) cosine = prod_sum / denom pos_value = 1.0 - cosine