jeanfeydy / geomloss

Geometric loss functions between point clouds, images and volumes
MIT License
570 stars 57 forks source link

Wasserstein distance for p not in {1,2} #62

Open gabrielfougeron opened 2 years ago

gabrielfougeron commented 2 years ago

Hi,

For the first time, I tried to used custom costs in Geomloss to compute W_p distances with general p. Using the "online" backend, I constructed a Loss with the following f-string as a cost : cost = f"(Powf(Scalprod(X-Y,X-Y),{p/2}) / {p})" For p=2, this gives cost = "(Powf(Scalprod(X-Y,X-Y),1.0) / 2)".

However, this fails with an attribute error :

File "/home/gfo/anaconda3/envs/ot-geomloss/lib/python3.9/site-packages/keopscore/formulas/VectorizedScalarOp.py", line 12, in dims = set(arg.dim for arg in args) AttributeError: 'float' object has no attribute 'dim'

The same error occurs using the expended exp( a log(b) ) instead of pow(b,a).

Am I doing something wrong ? Is this going to be addressed in the upcoming release ?

Best regards,