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

[MRG] Add a stablized function entropic_partial_wasserstein_logscale #724

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wzm2256
Copy link

@wzm2256 wzm2256 commented Mar 13, 2025

  1. add a new function called entropic_partial_wasserstein_logscale to ot.partial. This function solves the same problem as entropic_partial_wasserstein but is computed in logscale, so it is more robust.

  2. Test exampless are provided in compare_logscale_POT.py. Test data is in data\entropic_partial_OT_cost.txt

Types of changes

I implement a new function entropic_partial_wasserstein_logscale that solves exactly the same problem as the one in entropic_partial_wasserstein in log scale. The new function is a line-to-line translation of the old one, and the input/output format is exactly the same.

I do not remove the old function because the new function can be slower due to the use of the logsumexp trick. So when there is no Nan error, the old function is favored.

Motivation and context / Related issue

#723

How has this been tested (if it applies)

I test the new function entropic_partial_wasserstein_logscale against the old one entropic_partial_wasserstein in the example file 'compare_logscale_POT.py` for both numpy and pytorch.

  1. When eps is large, the old and new function produces exactly the same result
  2. When eps is small, the old function produce an error, but the new function works well.

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

I could not build the document in my laptop due to some errors:

Theme error:
no theme named 'sphinx_rtd_theme' found (missing theme.toml?)

so I am not completely sure whether the document is fine, although I only added a few sentences to the docs.

Also, I do not know how to use pytest to test my code. If this is necessary, I may need some help here.

wzm2256 added 2 commits March 13, 2025 11:43
ot.partial. This function solves the same problem as
entropic\_partial\_wasserstein but is computed in logscale, so it is
more robust.

2. Test exampless are provided in compare_logscale_POT.py. Test data is
   in data\entropic_partial_OT_cost.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant