# Don't average the loss

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdont-average-the-loss%2F36872%3E%5C
**Category:** Models\
**Created:** [April 17, 2023, 5:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdont-average-the-loss%2F36872 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsurya-narayanan)%5C
**Post date:** [April 17, 2023, 5:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdont-average-the-loss%2F36872%2F1 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FL4m3r)%5C
**Post date:** [March 30, 2024, 2:18am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdont-average-the-loss%2F36872%2F2 "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!
