# Multiple Loss Tracking on Train and Evaluate Steps

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmultiple-loss-tracking-on-train-and-evaluate-steps%2F138104%3E%5C
**Category:** 🤗Transformers\
**Created:** [January 30, 2025, 10:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmultiple-loss-tracking-on-train-and-evaluate-steps%2F138104 "2025-01-30T10:41:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilgeak](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@bilgeak](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbilgeak)%5C
**Post date:** [January 30, 2025, 10:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmultiple-loss-tracking-on-train-and-evaluate-steps%2F138104%2F1 "2025-01-30T10:41:34Z")

</div>

Hello  
I am using transformers 4.45.2  
I created a model with two different tasks (so two different losses) and can train it fine. But I wanted to explicitly track both of my losses, not only single loss, during training and eval steps.  
I have found some work arounds to partially solve the issue, but they don’t seem like clean solutions to me and all of them failed at some detail.  
My model already returns loss\_total, loss\_an and loss\_b and some other things in its output.  
Obviously, without modification, trainer only prints out loss\_total.  
I want to see all 3 losses, and also on epoch end, where the evaluation happens, I want to see these values on my evaluation dataset.  
On epoch end, I want to see  
train\_total\_loss, validation\_total\_loss, train\_loss\_a, train\_loss\_b, validation\_loss\_a, validation\_loss\_b.

Is there a clean solution for this  
Thanks

---

<div class="post-metadata">

**Author:** ![bilgeak](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@bilgeak](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbilgeak)%5C
**Post date:** [January 30, 2025, 10:43am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmultiple-loss-tracking-on-train-and-evaluate-steps%2F138104%2F2 "2025-01-30T10:43:09Z")

</div>

BTW, I tried  
1- customizing the trainer class  
2- using callbacks  
3- using compute\_metrics

---

<div class="post-metadata">

**Author:** ![ifaposto](https://avatars.discourse-cdn.com/v4/letter/i/ba8739/32.png) [@ifaposto](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fifaposto)%5C
**Post date:** [February 25, 2025, 2:12am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmultiple-loss-tracking-on-train-and-evaluate-steps%2F138104%2F3 "2025-02-25T02:12:35Z")

</div>

it would be very helpful prediction\_step to support a dictionary of losses

---

<div class="post-metadata">

**Author:** ![bilgeak](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@bilgeak](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbilgeak)%5C
**Post date:** [February 26, 2025, 8:51am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmultiple-loss-tracking-on-train-and-evaluate-steps%2F138104%2F4 "2025-02-26T08:51:29Z")

</div>

Actually after spending some time trying to modify trainer class etc I gave up and wrote my trainer with PyTorch.  
I would recommend you the same if you are tackling with multiple losses
