Skip to content

Commit 8b38097

Browse files
Sukjun Hwangfacebook-github-bot
authored andcommitted
Fix reduction of cross_entropy
Summary: Reduction of cross_entropy is always set to "mean". Fixed to receive the reduction. Pull Request resolved: #3454 Reviewed By: zhanghang1989 Differential Revision: D31052191 Pulled By: ppwwyyxx fbshipit-source-id: 0bd992cac13c67a772fac8539ab5cc4f7c8e5c3c
1 parent 018fca8 commit 8b38097

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

detectron2/layers/wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def cross_entropy(input, target, *, reduction="mean", **kwargs):
3030
"""
3131
if target.numel() == 0 and reduction == "mean":
3232
return input.sum() * 0.0 # connect the gradient
33-
return F.cross_entropy(input, target, **kwargs)
33+
return F.cross_entropy(input, target, reduction=reduction, **kwargs)
3434

3535

3636
class _NewEmptyTensorOp(torch.autograd.Function):

0 commit comments

Comments
 (0)