-
Notifications
You must be signed in to change notification settings - Fork 540
[MRG] Gracefully handle cost = 0 in generic_conditional_gradient
#505
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] Gracefully handle cost = 0 in generic_conditional_gradient
#505
Conversation
generic_conditional_gradientgeneric_conditional_gradient
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #505 +/- ##
=======================================
Coverage 96.25% 96.25%
=======================================
Files 67 67
Lines 14040 14043 +3
=======================================
+ Hits 13514 13517 +3
Misses 526 526 |
|
Hello @kachayev, Good catch ! However I am not sure that setting 'relative-delta_cost_G = np.nan' if 'cost_G = 0' is the most appropriate, as it would imply '(relative_delta_cost_G < stopThr) == False'. Then let the condition 'abs_delta_cost_G < stopThr2' handles the job, probably given 1 more round of the CG loop. On one hand, in several cases the cost is non-negative so we might want to force the loop to stop. On the other hand, this cg solver is meant to be as generic as possible. So maybe the best approach would be to add an optional parameter that allows to control this behaviour. Wdyt @kachayev @rflamary ? |
|
I basically set it to 'man' to have the same behavior it has right now, just without performing division. We could add additional flag to force exit from the loop when 0 is reached. Though for continuous space feels like an edge case. Should it be a parameter to stop when the cost is lower than given 'eps' rather than "exactly 0"? 🤔 |
|
Hello @kachayev, Overall, I think that it would be nice to go a normalisation of stopping criterions for various solvers (at least two consistent types) in POT. So our current interrogations could be handled in this context. Best, Cédric. |
generic_conditional_gradientgeneric_conditional_gradient
Types of changes
relative_delta_cost_Gingeneric_conditional_gradientis only computed when the cost != 0.Motivation and context / Related issue
As the contract for cost evaluation in
generic_conditional_gradientis rather generic, it could be the case it's set to 0. In this case computingrelative_delta_cost_Gfails because of zero division. As we only need the value ofrelative_delta_cost_Gfor early stopping condition, it doesn't hurt to skip the computation when cost is 0.The code to reproduce the issue:
How has this been tested (if it applies)
This actually happens in
test_gromov_dtype_devicetest case. The test case is not modified to ensure we don't have warnings when computingot.gromov.gromov_wasserstein.PR checklist