You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
POT generating incorrect result for very simple OT problem #345
Thank you for reporting this, I can reproduce the bug indeed.
This code here finds the correct OT plan:
importnumpyasnpimportotphi=np.array((0.5, 0.5)) # distribution 1psi=np.array((0.5, 0.5)) # distribution 2c= ((2, 1),
(1, 1.0))
c=np.array(c)
pi=ot.emd(phi, psi, c)
Interestingly if I put a unique float in the tuple defining C it works so it seems to be a problem of type wher integer values of C do not find a solution. Will look into it
found it! The backend forces the type of the output to be the same as the type of C which in your case is an integer and sets everything to 0 when rounding. This is done so as to ensure that you can solve emd across pytorch or tensorflow and returns the same type/device as the input.
Maybe we should enforce the output type to be the type of phi/psi? Not sure if it is a good idea a warning for C of integer type is probably better. In any case we need to update the doc to make this more clear.
Activity
rflamary commentedon Feb 7, 2022
Thank you for reporting this, I can reproduce the bug indeed.
This code here finds the correct OT plan:
Interestingly if I put a unique float in the tuple defining C it works so it seems to be a problem of type wher integer values of C do not find a solution. Will look into it
rflamary commentedon Feb 7, 2022
found it! The backend forces the type of the output to be the same as the type of C which in your case is an integer and sets everything to 0 when rounding. This is done so as to ensure that you can solve emd across pytorch or tensorflow and returns the same type/device as the input.
Maybe we should enforce the output type to be the type of phi/psi? Not sure if it is a good idea a warning for C of integer type is probably better. In any case we need to update the doc to make this more clear.