[MRG] Add a stablized function entropic_partial_wasserstein_logscale #724
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 inentropic_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 oneentropic_partial_wasserstein
in the example file 'compare_logscale_POT.py` for both numpy and pytorch.PR checklist
I could not build the document in my laptop due to some errors:
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.