Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve train loss metric logged in examples #399

Merged
merged 1 commit into from
May 26, 2022

Conversation

pacman100
Copy link
Contributor

What does this PR do?

  1. Train loss being logged wasn't normalized and as such wasn't intuitive to understand. This also made it difficult to compare train loss between different tools such as comparing train loss from Trainer with that of Accelerate. This PR normalizes the train_loss per epoch to make is more intuitive and comparable.

@pacman100 pacman100 requested a review from sgugger May 26, 2022 06:42
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 26, 2022

The documentation is not available anymore as the PR was closed or merged.

@pacman100 pacman100 changed the title improve metrics logged in examples improve train loss metric logged in examples May 26, 2022
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing!

@pacman100 pacman100 merged commit d1f7f99 into huggingface:main May 26, 2022
@pacman100 pacman100 deleted the smangrul/improve-examples branch May 26, 2022 11:59
@benjpau
Copy link

benjpau commented Aug 2, 2022

@pacman100 @sgugger In a multi-gpu environment, does the total_loss here represent the loss of all training data in the entire epoch or just the loss of training data on the main process?

I tried to print the result of total_loss on each process, and it seems that accelerator.log() only records the total_loss on the main process. So, please, do I need to use accelerator.gather() to get the training loss on the whole epoch? I hope I can get your confirmation, many thanks!

@pacman100
Copy link
Contributor Author

Hello @benjpau , yes, you are correct, you would need to gather to get the total epoch loss. Will raise a PR to fix the examples to reflect the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants