From f67b3f69fcdb09480f3ff0b7da5496f235dff1b7 Mon Sep 17 00:00:00 2001 From: zhangyanhui Date: Tue, 10 Jan 2023 10:48:46 +0800 Subject: [PATCH] BCEGrad bugfix for loss calculation when reduction is Mean --- .../cpu/kernel/nnacl/fp32_grad/binary_cross_entropy_grad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32_grad/binary_cross_entropy_grad.c b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32_grad/binary_cross_entropy_grad.c index a31927479f9..12d203563c1 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32_grad/binary_cross_entropy_grad.c +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32_grad/binary_cross_entropy_grad.c @@ -37,7 +37,7 @@ int BinaryCrossEntropyGrad(const int input_size, const int reduction, const floa } } else { float dloss1 = dloss[0]; - if (reduction == Reduction_Sum) { + if (reduction == Reduction_Mean) { dloss1 = dloss[0] / input_size; } for (int i = 0; i < input_size; i++) {