-
Notifications
You must be signed in to change notification settings - Fork 8
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
Reorganize sinkhorn_unbalanced
, improve convergence checks, and fix GPU issues
#80
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Pull Request Test Coverage Report for Build 883952337Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
sinkhorn_unbalanced
and improve convergence checkssinkhorn_unbalanced
, improve convergence checks, and fix GPU issues
function sinkhorn_unbalanced2(μ, ν, C, λ1, λ2, ε; plan=nothing, kwargs...) | ||
function sinkhorn_unbalanced2( | ||
μ, ν, C, λ1_or_proxdivF1, λ2_or_proxdivF2, ε; plan=nothing, kwargs... | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we rename to sinkhorn_unbalanced_cost
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. I still think the main problem is not the name of the functions but the amount of functions - they are all doing the same thing but for slightly different problems (many even for the same) and different algorithms. So the natural approach would be to be able to dispatch both on the problem and the algorithm, which would also solve the problem that #66 tries to address but doesn't fix in a general and extendable way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, I would suggest that both renaming and reorganization of functions should be done in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you are right. It's better that we decide on the naming, and then submit in another PR.
" I still think the main problem is not the name of the functions but the amount of functions - they are all doing the same thing but for slightly different problems (many even for the same) and different algorithms." Why is this a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a problem since if we have different functions for every combination of problem and algorithm (such as e.g. sinkhorn
, sinkhorn_stabilized
, sinkhorn_stabilized_epsscaling
, sinkhorn_unbalanced
etc.)
- the API is unstructured and difficult to navigate for users,
- it is very difficult to compose functionality (e.g. if I would like to use epsilon scaling with the unbalanced Sinkhorn algorithm I have to write a new function instead of just composing epsilon scaling with the unbalanced algorithm),
- we completely neglect multiple dispatch which arguably is the biggest feature of Julia.
…nsport.jl into dw/sinkhorn_unbalanced
Codecov Report
@@ Coverage Diff @@
## master #80 +/- ##
==========================================
+ Coverage 85.93% 88.36% +2.42%
==========================================
Files 1 1
Lines 256 275 +19
==========================================
+ Hits 220 243 +23
+ Misses 36 32 -4
Continue to review full report at Codecov.
|
This PR has a similar motivation as #79 and tries to fix some spurious test errors. However, I took the opportunity and rewrote large parts of the
sinkhorn_unbalanced
implementation and added more tests.The PR
atol
andrtol
options for a more fine-grained convergence analysis and deprecatestol
, similar to the other PR,0.5 * (err_a + err_b)
whereerr_a
anderr_b
are the relative distance w.r.t. inf-norm of the last two iterates ofa
andb
(same as in POT) toisapprox(vcat(a, b), vcat(a_old, b_old); atol, rtol)
(more efficiently implemented) based on the 2-norm,convergence_check
argument to adjust how often the convergence is checked,max_iter
tomaxiter
to be consistent withsinkhorn
,proxdiv_F1
andproxdiv_F2
and instead uses multiple dispatch,sinkhorn_unbalanced
and in particular gets rid of all unnecessary allocations and branches,Of course, one could use a different norm in the convergence check - as mentioned in the other PR, all standard norms are equivalent. However, in contrast to the marginal check in
sinkhorn
where one deals with probability measures there is no intuitive motivation for the use of the 1-norm for the scaling factors. Moreover, it seems a bit surprising to weight the errors ofa
andb
equally even though usually they are of different dimensions.Edit: I just checked, and the rewrite also fixes GPU issues. Currently, one can't use
sinkhorn_unbalanced
with CUDA but with this PR it is possible to just run