!13539 fix occasional precision failure of CosineEmbeddingLoss

From: @david-he91
Reviewed-by: @liangchenghui,@wuxuejian
Signed-off-by: @liangchenghui
This commit is contained in:
mindspore-ci-bot 2021-03-18 19:12:34 +08:00 committed by Gitee
commit 93c21f99e2
1 changed files with 1 additions and 1 deletions

View File

@ -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