extract dual potentials (φ, ψ) and their derivatives using POT #729
Replies: 1 comment
-
Hello @rouarouatbi , If you wish to interpolate between two shapes modelled as 2D points clouds, you can find many examples to do so here, such as that one or that one. This basically comes down to optimizing the support of the barycenter while fixing the masses associated to each point, and seems to better fit your synthetic dataset. In this case, if you still want potentials between an input and the barycenter, you'll have to compute ot.emd or ot.sinkhorn with This is quite different than the convolutional barycenter that only vary masses over a fixed grid (2D image), where you can also recover potentials settings |
Beta Was this translation helpful? Give feedback.
-
I've been using POT to solve 2D optimal transport problems involving transforming shapes (ellipse to circle, etc.), and I’ve run into an issue I couldn’t resolve after exploring several of the available APIs.
I tried ot.sinkhorn and the convolutional barycenter. however for the first didn't return reliable values, and the second seems to only return the barycenter.
This is an example of how I could define my source and target:
def S1(x, y, r):
O = np.zeros(len(x))
for k in range(len(x)):
if x[k]**2 + y[k]2 < r2:
O[k] = 1
return O / np.sum(O)
def S2(x, y, a, b):
O = np.zeros(len(x))
for k in range(len(x)):
if (x[k]2) / a2 + (y[k]2) / b2 < 1:
O[k] = 1
return O / np.sum(O)
r = 0.5
a = 0.5
b = 0.3
x = np.linspace(-1, 1, 50)
X_p, Y_p = np.meshgrid(x, x)
X_p_flat = X_p.flatten()
Y_p_flat = Y_p.flatten()
mu_s = S1(X_p_flat, Y_p_flat, r)
mu_t = S2(X_p_flat, Y_p_flat, a, b)
What I'm struggling with is a clear, stable example showing how to extract φ and ∇φ from any of the above APIs, or others.
Beta Was this translation helpful? Give feedback.
All reactions