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] OT for Gaussian distributions #428

Merged
merged 23 commits into from
Jan 16, 2023
Merged

Conversation

tgnassou
Copy link
Contributor

@tgnassou tgnassou commented Jan 12, 2023

Types of changes

This introduce Gaussian modules, a file comprising all the modules of optimal transport for Gaussian distributions.
The OT_mapping_linear moved from da.py to gaussian.py.
I added Bures Wasserstein distance to gaussian.py.
Also update examples/gromov/plot_barycenter_fgw.py to fit the new networkx API

Motivation and context / Related issue

Add new methods for Gaussian distributions.

How has this been tested (if it applies)

The test for Bures Wasserstein distance is done on two 1D Gaussian distributions centered on 0 and 10 respectively. with the same variance The Bures Wasserstein distance is tested to be close of 10.

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.

ot/datasets.py Outdated Show resolved Hide resolved
ot/gaussian.py Outdated Show resolved Hide resolved
ot/gaussian.py Outdated Show resolved Hide resolved
ot/gaussian.py Outdated Show resolved Hide resolved
ot/gaussian.py Outdated Show resolved Hide resolved
ot/gaussian.py Show resolved Hide resolved
test/test_gaussian.py Outdated Show resolved Hide resolved
ot/gaussian.py Outdated Show resolved Hide resolved
rflamary and others added 2 commits January 13, 2023 08:44
Co-authored-by: Alexandre Gramfort <[email protected]>
Co-authored-by: Alexandre Gramfort <[email protected]>
ot/gaussian.py Outdated Show resolved Hide resolved
ot/gaussian.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 13, 2023

Codecov Report

Merging #428 (1da6bc5) into master (058d275) will increase coverage by 0.17%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #428      +/-   ##
==========================================
+ Coverage   94.26%   94.43%   +0.17%     
==========================================
  Files          23       24       +1     
  Lines        6204     6254      +50     
==========================================
+ Hits         5848     5906      +58     
+ Misses        356      348       -8     

@tgnassou tgnassou changed the title [WIP] OT for Gaussian distributions [MRG] OT for Gaussian distributions Jan 15, 2023
ot/da.py Outdated
@@ -679,112 +680,12 @@ def df(G):
return G, L


@deprecated()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is enough since teh API did not change, also you did not apss the parameter to the function so it was false

Suggested change
@deprecated()
OT_mapping_linear=deprecated(empirical_bures_wasserstein_mapping)

ot/gaussian.py Outdated
Cs12 = nx.sqrtm(Cs)

B = nx.trace(Cs + Ct - 2 * nx.sqrtm(dots(Cs12, Ct, Cs12)))
W = nx.norm(ms - mt) + B
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
W = nx.norm(ms - mt) + B
W = nx.sqrt(nx.norm(ms - mt)**2 + B)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

norm shuould be squared and the Bures wassresein is the quare ropot of the term

ot/gaussian.py Outdated
Cs12 = nx.sqrtm(Cs)

B = nx.trace(Cs + Ct - 2 * nx.sqrtm(dots(Cs12, Ct, Cs12)))
W = nx.norm(mxs - mxt) + B
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same error here, you should call the function bures_wassrestein_distancehere anyways

@rflamary rflamary merged commit 97feeb3 into PythonOT:master Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants