How to get the loss history when use trainer.train()?

I am using the huggingface transformers. I noticed that when I call the train(), I can get a table contains the evaluation loss and training loss, how can I get the data in this table and use them to plot figures? (without wandb)

You should find them in Trainer.state.log_history. There is a parse_log_history function in the modelcard module that might be helpful to clean those logs.

2 Likes

Thank you !! I got it !!!

Can you please share how to do it?

Suppose you initialized:

trainer = transformers.Trainer(...)

Then you can access and convert the losses to dataframe by running

import pandas as pd
pd.DataFrame(trainer.state.log_history)
2 Likes