# Cross-entropy with one-hot targets

**URL:** <https://discuss.pytorch.org/t/cross-entropy-with-one-hot-targets/13580>\
**Category:** Uncategorized\
**Created:** [February 12, 2018, 10:29pm UTC](https://discuss.pytorch.org/t/cross-entropy-with-one-hot-targets/13580 "2018-02-12T22:29:41Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Dawid\_S](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dawid_s/32/15829_2.png) [@Dawid\_S](https://discuss.pytorch.org/u/Dawid_S)\
**Post date:** [February 14, 2018, 7:29am UTC](https://discuss.pytorch.org/t/cross-entropy-with-one-hot-targets/13580/7 "2018-02-14T07:29:12Z")

</div>

You’re right. I’ve heard however a few times (like here  
[Labels smoothing and categorical loss functions - alternatives?](https://discuss.pytorch.org/t/labels-smoothing-and-categorical-loss-functions-alternatives/11339)), that one can use BCELoss for soft targets somehow and I was trying to figure it out.

The function I defined above is twice faster than CrossEntropyFunction on cpu. It’s not a real reason but somehow I’m not sure I can trust it

---

_[View the full topic](https://discuss.pytorch.org/t/cross-entropy-with-one-hot-targets/13580)._
