Skip to content

Commit 354f8ff

Browse files
committed
add a demo in examples
1 parent 2878b6e commit 354f8ff

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import numpy as np
2+
from ot.gromov._gw import solve_gromov_linesearch
3+
from time import time
4+
5+
n = 1000
6+
7+
C1 = np.random.random((n, n))
8+
C1 = C1 + C1.T
9+
C2 = np.random.random((n, n))
10+
C2 = C2 + C2.T
11+
12+
G1 = np.ones((n, n)) / (n**2)
13+
G2 = np.eye(n) / n
14+
15+
tic = time()
16+
alpha2, _, _ = solve_gromov_linesearch(G1, G2 - G1, cost_G=0, C1=C1, C2=C2, M=0, reg=1, symmetric=False)
17+
tac = time()
18+
19+
print(f'Linesearch time without symmetric assumption {tac-tic}')
20+
21+
tic = time()
22+
alpha1, _, _ = solve_gromov_linesearch(G1, G2 - G1, cost_G=0, C1=C1, C2=C2, M=0, reg=1, symmetric=True)
23+
tac = time()
24+
25+
print(f'Linesearch time with symmetric assumption {tac-tic}')
26+
27+
assert alpha1 == alpha2

0 commit comments

Comments
 (0)