# Don't average the loss

**URL:** <https://discuss.huggingface.co/t/dont-average-the-loss/36872>\
**Category:** Models\
**Created:** [April 17, 2023, 5:16pm UTC](https://discuss.huggingface.co/t/dont-average-the-loss/36872 "2023-04-17T17:16:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![surya-narayanan](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@surya-narayanan](https://discuss.huggingface.co/u/surya-narayanan)\
**Post date:** [April 17, 2023, 5:16pm UTC](https://discuss.huggingface.co/t/dont-average-the-loss/36872/1 "2023-04-17T17:16:56Z")

</div>

Hi,

I was wondering if there was a way to not average the loss over all examples of a batch- I want to get the losses as a vector of (batchsize , 1) and not (1, 1).

Is that possible?

---

<div class="post-metadata">

**Author:** ![L4m3r](https://avatars.discourse-cdn.com/v4/letter/l/b77776/32.png) [@L4m3r](https://discuss.huggingface.co/u/L4m3r)\
**Post date:** [March 30, 2024, 2:18am UTC](https://discuss.huggingface.co/t/dont-average-the-loss/36872/2 "2024-03-30T02:18:29Z")

</div>

I would like to do the same thing while the direct way I’ve found this moment is to forward batchsize times (stupid enough for me 😵). Is there a more appropriate way to achieve this result? Please share with me, thanks!
