pytorch / torcheval

A library that contains a rich collection of performant PyTorch model metrics, a simple interface to create new metrics, a toolkit to facilitate metric computation in distributed training and tools for PyTorch model evaluations.
https://pytorch.org/torcheval
Other
214 stars 46 forks source link

Wasserstein #184

Closed GaganCodes closed 11 months ago

GaganCodes commented 11 months ago

Summary: Implemented the wasserstein distance function and metric class for 1 dimensional case.

Test plan: Every feature of the code is tested via unitTest framework in "torcheval\tests\metrics\statistical\test_wasserstein.py" and "torcheval\tests\metrics\functional\statistical\test_wasserstein.py".

Fixes #{issue number} https://github.com/pytorch/torcheval/issues/137

codecov[bot] commented 11 months ago

Codecov Report

Merging #184 (4a47eaf) into main (a975ef6) will increase coverage by 0.01%. The diff coverage is 96.24%.

@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
+ Coverage   95.71%   95.73%   +0.01%     
==========================================
  Files         178      184       +6     
  Lines       10278    10571     +293     
==========================================
+ Hits         9838    10120     +282     
- Misses        440      451      +11     
Files Coverage Δ
tests/metrics/statistical/test_wasserstein.py 100.00% <100.00%> (ø)
...rcheval/metrics/functional/statistical/__init__.py 100.00% <100.00%> (ø)
torcheval/metrics/statistical/__init__.py 100.00% <100.00%> (ø)
torcheval/metrics/statistical/wasserstein.py 100.00% <100.00%> (ø)
torcheval/utils/random_data.py 100.00% <100.00%> (ø)
...eval/metrics/functional/statistical/wasserstein.py 90.90% <90.90%> (ø)
...metrics/functional/statistical/test_wasserstein.py 93.40% <93.40%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

bobakfb commented 11 months ago

Also looks like there are some linting errors, could you make sure to run pre-commit and fix?

GaganCodes commented 11 months ago

Thank you for the quick feedback @bobakfb, I'll fix these and get back to you ASAP.

facebook-github-bot commented 11 months ago

@bobakfb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

GaganCodes commented 11 months ago

@bobakfb code lint and extra files comments are resolved. Thanks!

facebook-github-bot commented 11 months ago

@bobakfb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

GaganCodes commented 11 months ago

Hi @bobakfb , @ananthsub , I am not sure why pre-commit is failing for flake8, it's showing "Passed" on my local machine. I have also manually ensured that no imported module is unused.

For transparency, python version on my machine is 3.10.12, whereas in pre-commit check here it seems to be 3.12.0.

facebook-github-bot commented 11 months ago

@bobakfb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.