Skip to content

[MRG] Initialization for Low Rank Sinkhorn solver #588

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

Merged
merged 47 commits into from
Dec 21, 2023

Conversation

laudavid
Copy link
Contributor

@laudavid laudavid commented Dec 6, 2023

Hello Rémi,

Here is a PR to add initialization strategies to the low rank sinkhorn solver (for Q, R, g).
I added a "random", "trivial" and "kmeans" strategy and created a new function _init_lr_sinkhorn to implement them.

laudavid and others added 30 commits October 24, 2023 14:54
@rflamary rflamary changed the title Initialization for Low Rank Sinkhorn solver [WIP] Initialization for Low Rank Sinkhorn solver Dec 6, 2023
Copy link
Collaborator

@cedricvincentcuaz cedricvincentcuaz left a comment

Choose a reason for hiding this comment

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

Hello @laudavid,

thanks a lot for your PR.
Here are a few remarks to fix and also questions to clarify some points.

Best,
Cédric

ot/lowrank.py Outdated
R = nx.abs(nx.randn(nt, rank, type_as=X_s)) + 1
R = (R.T * (b / nx.sum(R, axis=1))).T

if init == "trivial":
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably the most "trivial" init to do would be to set g uniform and deduce Q (resp. R) following equations in lines 84-85 (resp. 88-89). Would such initialization be of interest ? is trivial a proper name for this other deterministic init ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This initialization strategy was called "trivial" by the researchers.
I don't really know how to name it otherwise.

I can also remove this option for init, since there is also a "random" and "kmeans" option.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe 'deterministic', to contrast to 'random' which are the two initializations which are data independent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. I'll change it to "deterministic".

Copy link

codecov bot commented Dec 20, 2023

Codecov Report

Merging #588 (077184f) into master (0024d07) will increase coverage by 0.01%.
The diff coverage is 97.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #588      +/-   ##
==========================================
+ Coverage   96.73%   96.74%   +0.01%     
==========================================
  Files          77       77              
  Lines       15820    15911      +91     
==========================================
+ Hits        15303    15393      +90     
- Misses        517      518       +1     

Copy link
Collaborator

@cedricvincentcuaz cedricvincentcuaz left a comment

Choose a reason for hiding this comment

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

Few last corrections in the code for the example and default values, and then we will be ready to merge ;)

ot/lowrank.py Outdated
R = nx.abs(nx.randn(nt, rank, type_as=X_s)) + 1
R = (R.T * (b / nx.sum(R, axis=1))).T

if init == "trivial":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe 'deterministic', to contrast to 'random' which are the two initializations which are data independent.

@rflamary rflamary changed the title [WIP] Initialization for Low Rank Sinkhorn solver [MRG] Initialization for Low Rank Sinkhorn solver Dec 21, 2023
@rflamary rflamary merged commit f5fbdd6 into PythonOT:master Dec 21, 2023
cedricvincentcuaz pushed a commit that referenced this pull request May 29, 2024
* new file for lr sinkhorn

* lr sinkhorn, solve_sample, OTResultLazy

* add test functions + small modif lr_sin/solve_sample

* add import to __init__

* modify low rank, remove solve_sample,OTResultLazy

* new file for lr sinkhorn

* lr sinkhorn, solve_sample, OTResultLazy

* add test functions + small modif lr_sin/solve_sample

* add import to __init__

* remove test solve_sample

* add value, value_linear, lazy_plan

* add comments to lr algorithm

* modify test functions + add comments to lowrank

* modify __init__ with lowrank

* debug lowrank + test

* debug test function low_rank

* error test

* final debug of lowrank + add new test functions

* Debug tests + add lowrank to solve_sample

* fix torch backend for lowrank

* fix jax backend and skip tf

* fix pep 8 tests

* add lowrank init + test functions

* Add init strategies in lowrank + example (#588)

* modified lowrank

* changes from code review

* fix error test pep8

* fix linux-minimal-deps + code review

* Implementation of LR GW + add method in __init__

* add LR gw paper in README.md

* add tests for low rank GW

* add examples for Low Rank GW

* fix __init__

* change atol of lr backends

* fix pep8 errors

* modif for code review
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