Skip to content

Conversation

adosar
Copy link

@adosar adosar commented Oct 4, 2025

What does this PR do?

Improves the documentation for logging a metric only on epoch-level.

In the docs we find the following hint:

When using any Modular metric, calling self.metric(...) or self.metric.forward(...) serves the dual purpose
of calling self.metric.update() on its input and simultaneously returning the metric value over the provided
input. So if you are logging a metric only on epoch-level (as in the example above), it is recommended to call
self.metric.update() directly to avoid the extra computation.

The original documentation snippet is intended to illustrate logging a metric only on epoch-level. However, the snippet sets on_step=True, which contradicts the stated motivation. Changed it to on_step=False to ensure the example correctly demonstrates logging only on epoch-level.

Fixes #<issue_number>

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃


📚 Documentation preview 📚: https://torchmetrics--3282.org.readthedocs.build/en/3282/

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 4, 2025
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37%. Comparing base (122a852) to head (e1141d2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #3282    +/-   ##
=======================================
- Coverage      37%     37%    -1%     
=======================================
  Files         364     349    -15     
  Lines       20096   19901   -195     
=======================================
- Hits         7520    7326   -194     
+ Misses      12576   12575     -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify bot added the ready label Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants