Inconsistency CrossEntropyLoss
vs BCELoss
regarding logits/probability space
#128493
Labels
module: nn
Related to torch.nn
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
馃殌 The feature, motivation and pitch
The loss
CrossEntropyLoss
expects logits inputs. On the other hand, there existBCELoss
andBCEWithLogitsLoss
. But there is no counterpart toCrossEntropyLoss
that expects inputs in the probability space.Alternatives
I think it would make more sense if
CrossEntropyLoss
expected probability inputs and if a newCrossEntropyWithLogitsLoss
was introduced. But this would be a dramatic change in the API.As such, I would propose to introduce an option
with_logits
(that defaults toTrue
to keep compatibility) toCrossEntropyLoss
.What do you think?
Additional context
Finally, I ask the following questions:
CrossEntropyLoss
counterpart for probability space, the user is forced to add a extra step and useNLLLoss
or write a custom loss.CrossEntropyLoss
doesn't work with probability space due to under/overflow handling in general?Thanks!
cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki
The text was updated successfully, but these errors were encountered: