Skip to content
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

Problem when using "Exact" method to calculate large samples #23

Open
chenmzh opened this issue Mar 11, 2022 · 3 comments
Open

Problem when using "Exact" method to calculate large samples #23

chenmzh opened this issue Mar 11, 2022 · 3 comments

Comments

@chenmzh
Copy link

chenmzh commented Mar 11, 2022

When I tried to calculate the "exact" distance between two large datasets (with 2 labels and more than 10000 samples in total), the error would raise:

TypeError                                 Traceback (most recent call last)
~/otdd/otdd/pytorch/wasserstein.py in pwdist_exact(X1, Y1, X2, Y2, symmetric, loss, cost_function, p, debias, entreg, device)
    335         try:
--> 336             D[i, j] = distance(X1[Y1==c1[i]].to(device), X2[Y2==c2[j]].to(device)).item()
    337         except:

~/test/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
   1101                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1102             return forward_call(*input, **kwargs)
   1103         # Do not call functions when jit is used

~/test/lib/python3.7/site-packages/geomloss-0.2.4-py3.7.egg/geomloss/samples_loss.py in forward(self, *args)
    283             labels_y=l_y,
--> 284             verbose=self.verbose,
    285         )

~/test/lib/python3.7/site-packages/geomloss-0.2.4-py3.7.egg/geomloss/sinkhorn_samples.py in sinkhorn_online(α, x, β, y, p, blur, reach, diameter, scaling, cost, debias, potentials, **kwargs)
    142     softmin = partial(
--> 143         softmin_online, log_conv=keops_lse(cost, D, dtype=str(x.dtype)[6:])
    144     )

~/test/lib/python3.7/site-packages/geomloss-0.2.4-py3.7.egg/geomloss/sinkhorn_samples.py in keops_lse(cost, D, dtype)
    107 #         "( B - (P * " + cost + " ) )",
--> 108         "( B - (P * " + cost+ " ) )",
    109         "A = Vi(1)",
TypeError: can only concatenate str (not "function") to str

I wonder would it be possible to use "exact" method to compute a large number of samples? Thanks

@xlcbingo1999
Copy link

I met the same issue with you. If you solve this problem?

@chenmzh
Copy link
Author

chenmzh commented Mar 10, 2023

If I remember correct, there are some hard coded limitation inside the code. Not tested since last April, maybe there are difference now

@xlcbingo1999
Copy link

If I remember correct, there are some hard coded limitation inside the code. Not tested since last April, maybe there are difference now

OK. Thanks for your help! I changed the lambda expression, then fixed the Error. But I got a slow speed for calculating the distance between two datasets.

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

No branches or pull requests

2 participants