PythonOT/POT

`gromov_wasserstein` returning the zero array as the optimal coupling

Closed this issue · 2 comments

Describe the bug

gromov_wasserstein returns the zero matrix as a coupling after calculation.

To Reproduce

# Run on Google Colab
!pip install pot
import numpy as np 
import scipy
import ot

# Define two discrete distributions (source and target)
source_dist = np.array([0.5, 0.1, 0.2, 0.2])
target_dist = np.array([0.1, 0.3, 0.4, 0.2])

# Define the cost matrices for each distribution
cost_matrix_source = np.array([[np.abs(i-j) for j in range(len(source_dist))] for i in range(len(source_dist))])
cost_matrix_target = np.array([[np.abs(i-j) for j in range(len(target_dist))] for i in range(len(target_dist))])

# Compute the Gromov-Wasserstein distance
gw = ot.gromov.gromov_wasserstein(cost_matrix_source, cost_matrix_target, source_dist, target_dist)

print("Gromov-Wasserstein Optimal Coupling:")
print(gw)

Result:

Gromov-Wasserstein Optimal Coupling:
[[0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]]

Expected behavior

It should return a matrix that satisfies the coupling constraint i.e. each row/column sums up to the source/target distributions.

Environment:

Linux-5.15.120+-x86_64-with-glibc2.35
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
NumPy 1.23.5
SciPy 1.11.3
POT 0.9.1
``

Hello @mao1756 ,

I believe an answer is provided in the closed issue #530 .

@cedricvincentcuaz Ah, that makes sense. Thank you for your help.