BCEGrad bugfix for loss calculation when reduction is Mean

Merge pull request  from zhangyanhui/code_mas
This commit is contained in:
i-robot 2023-01-10 08:22:31 +00:00 committed by Gitee
commit 560e83bad0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 1 additions and 1 deletions
mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32_grad

View File

@ -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++) {