From f724f9ac4f0c60369d46d3a4881660c7a4698c7a Mon Sep 17 00:00:00 2001
From: qiang chen <qiang.chen@nlpr.ia.ac.cn>
Date: Fri, 21 Jun 2019 18:47:04 +0800
Subject: [PATCH] fix potential bug in binary_cross_entropy (#846)

---
 mmdet/models/losses/cross_entropy_loss.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mmdet/models/losses/cross_entropy_loss.py b/mmdet/models/losses/cross_entropy_loss.py
index 2f2ce69..b7bab12 100644
--- a/mmdet/models/losses/cross_entropy_loss.py
+++ b/mmdet/models/losses/cross_entropy_loss.py
@@ -29,14 +29,13 @@ def binary_cross_entropy(pred,
     if pred.dim() != label.dim():
         label, weight = _expand_binary_labels(label, weight, pred.size(-1))
 
-    # element-wise losses
+    # weighted element-wise losses
     if weight is not None:
         weight = weight.float()
     loss = F.binary_cross_entropy_with_logits(
         pred, label.float(), weight, reduction='none')
-    # apply weights and do the reduction
-    loss = weight_reduce_loss(
-        loss, weight=weight, reduction=reduction, avg_factor=avg_factor)
+    # do the reduction for the weighted loss
+    loss = weight_reduce_loss(loss, reduction=reduction, avg_factor=avg_factor)
 
     return loss
 
-- 
GitLab