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

Fix consistency in the output of scalar tensors #622

Merged
merged 15 commits into from
Nov 24, 2021
Merged

Conversation

SkafteNicki
Copy link
Member

@SkafteNicki SkafteNicki commented Nov 15, 2021

What does this PR do?

Fixes #611
Trying to fix consistency in the output of metrics. If a metric returns a scalar tensor, then sometimes it is

tensor([...])

and other times it is:

tensor(...)

This PR fixes this by doing a squeeze after compute if the output has numel=1.

Before submitting

  • Was this discussed/approved 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 🙃

@SkafteNicki SkafteNicki added the enhancement New feature or request label Nov 15, 2021
@SkafteNicki SkafteNicki added this to the v0.7 milestone Nov 15, 2021
@codecov
Copy link

codecov bot commented Nov 15, 2021

Codecov Report

Merging #622 (f1789e0) into master (02ea8de) will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff          @@
##           master   #622   +/-   ##
=====================================
  Coverage      95%    95%           
=====================================
  Files         155    155           
  Lines        5508   5513    +5     
=====================================
+ Hits         5236   5244    +8     
+ Misses        272    269    -3     

@mergify mergify bot added the ready label Nov 15, 2021
@Borda Borda enabled auto-merge (squash) November 19, 2021 21:24
@mergify mergify bot removed the ready label Nov 23, 2021
@mergify mergify bot removed the has conflicts label Nov 23, 2021
torchmetrics/image/lpip_similarity.py Outdated Show resolved Hide resolved
torchmetrics/regression/pearson.py Outdated Show resolved Hide resolved
torchmetrics/classification/kl_divergence.py Outdated Show resolved Hide resolved
torchmetrics/aggregation.py Outdated Show resolved Hide resolved
torchmetrics/aggregation.py Outdated Show resolved Hide resolved
torchmetrics/aggregation.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready label Nov 24, 2021
@Borda Borda merged commit ce2d1c7 into master Nov 24, 2021
@Borda Borda deleted the squeeze_1_element_tensor branch November 24, 2021 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MeanMetric conflicts with EarlyStopping
4 participants