@@ -343,20 +343,33 @@ def entropic_gromov_wasserstein2(
343
343
return logv ['gw_dist' ]
344
344
345
345
346
- def entropic_BAPG_gromov_wasserstein (
346
+ def BAPG_gromov_wasserstein (
347
347
C1 , C2 , p = None , q = None , loss_fun = 'square_loss' , epsilon = 0.1 ,
348
348
symmetric = None , G0 = None , max_iter = 1000 , tol = 1e-9 , marginal_loss = False ,
349
349
verbose = False , log = False ):
350
350
r"""
351
351
Returns the Gromov-Wasserstein transport between :math:`(\mathbf{C_1}, \mathbf{p})` and :math:`(\mathbf{C_2}, \mathbf{q})`
352
352
estimated using Bregman Alternated Projected Gradient method.
353
353
354
- The function solves the following Gromov-Wasserstein
355
- optimization problem [63] :
354
+ If `marginal_loss=True`, the function solves the following Gromov-Wasserstein
355
+ optimization problem :
356
356
357
357
.. math::
358
358
\mathbf{T}^* \in \mathop{\arg\min}_\mathbf{T} \quad \sum_{i,j,k,l} L(\mathbf{C_1}_{i,k}, \mathbf{C_2}_{j,l}) \mathbf{T}_{i,j} \mathbf{T}_{k,l}
359
359
360
+ s.t. \ \mathbf{T} \mathbf{1} &= \mathbf{p}
361
+
362
+ \mathbf{T}^T \mathbf{1} &= \mathbf{q}
363
+
364
+ \mathbf{T} &\geq 0
365
+
366
+ Else, the function solves an equivalent problem [63], where constant terms only
367
+ depending on the marginals :math:`\mathbf{p}`: and :math:`\mathbf{q}`: are
368
+ discarded while assuming that L decomposes as in Proposition 1 in [12]:
369
+
370
+ .. math::
371
+ \mathbf{T}^* \in\mathop{\arg\min}_\mathbf{T} \quad - \langle h_1(\mathbf{C}_1) \mathbf{T} h_2(\mathbf{C_2})^\top , \mathbf{T} \rangle_F
372
+
360
373
s.t. \ \mathbf{T} \mathbf{1} &= \mathbf{p}
361
374
362
375
\mathbf{T}^T \mathbf{1} &= \mathbf{q}
@@ -369,6 +382,7 @@ def entropic_BAPG_gromov_wasserstein(
369
382
- :math:`\mathbf{p}`: distribution in the source space
370
383
- :math:`\mathbf{q}`: distribution in the target space
371
384
- `L`: loss function to account for the misfit between the similarity matrices
385
+ satisfying :math:`L(a, b) = f_1(a) + f_2(b) - h_1(a) h_2(b)`
372
386
373
387
.. note:: By algorithmic design the optimal coupling :math:`\mathbf{T}`
374
388
returned by this function does not necessarily satisfy the marginal
@@ -407,7 +421,7 @@ def entropic_BAPG_gromov_wasserstein(
407
421
tol : float, optional
408
422
Stop threshold on error (>0)
409
423
marginal_loss: bool, optional. Default is False.
410
- Include constant terms or not in the matching objective function.
424
+ Include constant marginal terms or not in the objective function.
411
425
verbose : bool, optional
412
426
Print information along iterations
413
427
log : bool, optional
@@ -524,19 +538,33 @@ def df(T):
524
538
return T
525
539
526
540
527
- def entropic_BAPG_gromov_wasserstein2 (
541
+ def BAPG_gromov_wasserstein2 (
528
542
C1 , C2 , p = None , q = None , loss_fun = 'square_loss' , epsilon = 0.1 , symmetric = None , G0 = None , max_iter = 1000 ,
529
543
tol = 1e-9 , marginal_loss = False , verbose = False , log = False ):
530
544
r"""
531
545
Returns the Gromov-Wasserstein loss :math:`\mathbf{GW}` between :math:`(\mathbf{C_1}, \mathbf{p})` and :math:`(\mathbf{C_2}, \mathbf{q})`
532
546
estimated using Bregman Alternated Projected Gradient method.
533
547
534
- The function solves the following Gromov-Wasserstein
535
- optimization problem [63]:
548
+ If `marginal_loss=True`, the function solves the following Gromov-Wasserstein
549
+ optimization problem :
550
+
536
551
537
552
.. math::
538
553
\mathbf{GW} = \mathop{\min}_\mathbf{T} \quad \sum_{i,j,k,l} L(\mathbf{C_1}_{i,k}, \mathbf{C_2}_{j,l}) \mathbf{T}_{i,j} \mathbf{T}_{k,l}
539
554
555
+ s.t. \ \mathbf{T} \mathbf{1} &= \mathbf{p}
556
+
557
+ \mathbf{T}^T \mathbf{1} &= \mathbf{q}
558
+
559
+ \mathbf{T} &\geq 0
560
+
561
+ Else, the function solves an equivalent problem [63, 64], where constant terms only
562
+ depending on the marginals :math:`\mathbf{p}`: and :math:`\mathbf{q}`: are
563
+ discarded while assuming that L decomposes as in Proposition 1 in [12]:
564
+
565
+ .. math::
566
+ \mathop{\min}_\mathbf{T} \quad - \langle h_1(\mathbf{C}_1) \mathbf{T} h_2(\mathbf{C_2})^\top , \mathbf{T} \rangle_F
567
+
540
568
s.t. \ \mathbf{T} \mathbf{1} &= \mathbf{p}
541
569
542
570
\mathbf{T}^T \mathbf{1} &= \mathbf{q}
@@ -549,6 +577,7 @@ def entropic_BAPG_gromov_wasserstein2(
549
577
- :math:`\mathbf{p}`: distribution in the source space
550
578
- :math:`\mathbf{q}`: distribution in the target space
551
579
- `L`: loss function to account for the misfit between the similarity matrices
580
+ satisfying :math:`L(a, b) = f_1(a) + f_2(b) - h_1(a) h_2(b)`
552
581
553
582
.. note:: By algorithmic design the optimal coupling :math:`\mathbf{T}`
554
583
returned by this function does not necessarily satisfy the marginal
@@ -588,7 +617,7 @@ def entropic_BAPG_gromov_wasserstein2(
588
617
tol : float, optional
589
618
Stop threshold on error (>0)
590
619
marginal_loss: bool, optional. Default is False.
591
- Include constant terms or not in the matching objective function.
620
+ Include constant marginal terms or not in the objective function.
592
621
verbose : bool, optional
593
622
Print information along iterations
594
623
log : bool, optional
@@ -607,7 +636,7 @@ def entropic_BAPG_gromov_wasserstein2(
607
636
608
637
"""
609
638
610
- T , logv = entropic_BAPG_gromov_wasserstein (
639
+ T , logv = BAPG_gromov_wasserstein (
611
640
C1 , C2 , p , q , loss_fun , epsilon , symmetric , G0 , max_iter ,
612
641
tol , marginal_loss , verbose , log = True )
613
642
@@ -1153,7 +1182,7 @@ def entropic_fused_gromov_wasserstein2(
1153
1182
return logv ['fgw_dist' ]
1154
1183
1155
1184
1156
- def entropic_BAPG_fused_gromov_wasserstein (
1185
+ def BAPG_fused_gromov_wasserstein (
1157
1186
M , C1 , C2 , p = None , q = None , loss_fun = 'square_loss' , epsilon = 0.1 ,
1158
1187
symmetric = None , alpha = 0.5 , G0 = None , max_iter = 1000 , tol = 1e-9 ,
1159
1188
marginal_loss = False , verbose = False , log = False ):
@@ -1162,8 +1191,8 @@ def entropic_BAPG_fused_gromov_wasserstein(
1162
1191
with pairwise distance matrix :math:`\mathbf{M}` between node feature matrices :math:`\mathbf{Y_1}` and :math:`\mathbf{Y_2}`,
1163
1192
estimated using Bregman Alternated Projected Gradient method.
1164
1193
1165
- The function solves the following Fused Gromov-Wasserstein
1166
- optimization problem [63, 64] :
1194
+ If `marginal_loss=True`, the function solves the following Fused Gromov-Wasserstein
1195
+ optimization problem :
1167
1196
1168
1197
.. math::
1169
1198
\mathbf{T}^* \in\mathop{\arg\min}_\mathbf{T} \quad (1 - \alpha) \langle \mathbf{T}, \mathbf{M} \rangle_F +
@@ -1174,14 +1203,29 @@ def entropic_BAPG_fused_gromov_wasserstein(
1174
1203
\mathbf{T}^T \mathbf{1} &= \mathbf{q}
1175
1204
1176
1205
\mathbf{T} &\geq 0
1206
+
1207
+ Else, the function solves an equivalent problem [63, 64], where constant terms only
1208
+ depending on the marginals :math:`\mathbf{p}`: and :math:`\mathbf{q}`: are
1209
+ discarded while assuming that L decomposes as in Proposition 1 in [12]:
1210
+
1211
+ .. math::
1212
+ \mathbf{T}^* \in\mathop{\arg\min}_\mathbf{T} \quad (1 - \alpha) \langle \mathbf{T}, \mathbf{M} \rangle_F -
1213
+ \alpha \langle h_1(\mathbf{C}_1) \mathbf{T} h_2(\mathbf{C_2})^\top , \mathbf{T} \rangle_F
1214
+ s.t. \ \mathbf{T} \mathbf{1} &= \mathbf{p}
1215
+
1216
+ \mathbf{T}^T \mathbf{1} &= \mathbf{q}
1217
+
1218
+ \mathbf{T} &\geq 0
1219
+
1177
1220
Where :
1178
1221
1179
- - :math:`\mathbf{M}`: metric cost matrix between features across domains
1222
+ - :math:`\mathbf{M}`: pairwise relation matrix between features across domains
1180
1223
- :math:`\mathbf{C_1}`: Metric cost matrix in the source space
1181
1224
- :math:`\mathbf{C_2}`: Metric cost matrix in the target space
1182
1225
- :math:`\mathbf{p}`: distribution in the source space
1183
1226
- :math:`\mathbf{q}`: distribution in the target space
1184
1227
- `L`: loss function to account for the misfit between the similarity and feature matrices
1228
+ satisfying :math:`L(a, b) = f_1(a) + f_2(b) - h_1(a) h_2(b)`
1185
1229
- :math:`\alpha`: trade-off parameter
1186
1230
1187
1231
.. note:: By algorithmic design the optimal coupling :math:`\mathbf{T}`
@@ -1194,7 +1238,7 @@ def entropic_BAPG_fused_gromov_wasserstein(
1194
1238
Parameters
1195
1239
----------
1196
1240
M : array-like, shape (ns, nt)
1197
- Metric cost matrix between features across domains
1241
+ Pairwise relation matrix between features across domains
1198
1242
C1 : array-like, shape (ns, ns)
1199
1243
Metric cost matrix in the source space
1200
1244
C2 : array-like, shape (nt, nt)
@@ -1225,7 +1269,7 @@ def entropic_BAPG_fused_gromov_wasserstein(
1225
1269
tol : float, optional
1226
1270
Stop threshold on error (>0)
1227
1271
marginal_loss: bool, optional. Default is False.
1228
- Include constant terms or not in the matching objective function.
1272
+ Include constant marginal terms or not in the objective function.
1229
1273
verbose : bool, optional
1230
1274
Print information along iterations
1231
1275
log : bool, optional
@@ -1344,7 +1388,7 @@ def df(T):
1344
1388
return T
1345
1389
1346
1390
1347
- def entropic_BAPG_fused_gromov_wasserstein2 (
1391
+ def BAPG_fused_gromov_wasserstein2 (
1348
1392
M , C1 , C2 , p = None , q = None , loss_fun = 'square_loss' , epsilon = 0.1 ,
1349
1393
symmetric = None , alpha = 0.5 , G0 = None , max_iter = 1000 , tol = 1e-9 ,
1350
1394
marginal_loss = False , verbose = False , log = False ):
@@ -1353,8 +1397,8 @@ def entropic_BAPG_fused_gromov_wasserstein2(
1353
1397
with pairwise distance matrix :math:`\mathbf{M}` between node feature matrices :math:`\mathbf{Y_1}` and :math:`\mathbf{Y_2}`,
1354
1398
estimated using Bregman Alternated Projected Gradient method.
1355
1399
1356
- The function solves the following Fused Gromov-Wasserstein
1357
- optimization problem [63, 64] :
1400
+ If `marginal_loss=True`, the function solves the following Fused Gromov-Wasserstein
1401
+ optimization problem :
1358
1402
1359
1403
.. math::
1360
1404
\mathbf{FGW} = \mathop{\min}_\mathbf{T} \quad (1 - \alpha) \langle \mathbf{T}, \mathbf{M} \rangle_F +
@@ -1365,6 +1409,19 @@ def entropic_BAPG_fused_gromov_wasserstein2(
1365
1409
\mathbf{T}^T \mathbf{1} &= \mathbf{q}
1366
1410
1367
1411
\mathbf{T} &\geq 0
1412
+
1413
+ Else, the function solves an equivalent problem [63, 64], where constant terms only
1414
+ depending on the marginals :math:`\mathbf{p}`: and :math:`\mathbf{q}`: are
1415
+ discarded while assuming that L decomposes as in Proposition 1 in [12]:
1416
+
1417
+ .. math::
1418
+ \mathop{\min}_\mathbf{T} \quad (1 - \alpha) \langle \mathbf{T}, \mathbf{M} \rangle_F -
1419
+ \alpha \langle h_1(\mathbf{C}_1) \mathbf{T} h_2(\mathbf{C_2})^\top , \mathbf{T} \rangle_F
1420
+ s.t. \ \mathbf{T} \mathbf{1} &= \mathbf{p}
1421
+
1422
+ \mathbf{T}^T \mathbf{1} &= \mathbf{q}
1423
+
1424
+ \mathbf{T} &\geq 0
1368
1425
Where :
1369
1426
1370
1427
- :math:`\mathbf{M}`: metric cost matrix between features across domains
@@ -1373,6 +1430,7 @@ def entropic_BAPG_fused_gromov_wasserstein2(
1373
1430
- :math:`\mathbf{p}`: distribution in the source space
1374
1431
- :math:`\mathbf{q}`: distribution in the target space
1375
1432
- `L`: loss function to account for the misfit between the similarity and feature matrices
1433
+ satisfying :math:`L(a, b) = f_1(a) + f_2(b) - h_1(a) h_2(b)`
1376
1434
- :math:`\alpha`: trade-off parameter
1377
1435
1378
1436
.. note:: By algorithmic design the optimal coupling :math:`\mathbf{T}`
@@ -1416,7 +1474,7 @@ def entropic_BAPG_fused_gromov_wasserstein2(
1416
1474
tol : float, optional
1417
1475
Stop threshold on error (>0)
1418
1476
marginal_loss: bool, optional. Default is False.
1419
- Include constant terms or not in the matching objective function.
1477
+ Include constant marginal terms or not in the objective function.
1420
1478
verbose : bool, optional
1421
1479
Print information along iterations
1422
1480
log : bool, optional
@@ -1438,7 +1496,7 @@ def entropic_BAPG_fused_gromov_wasserstein2(
1438
1496
"""
1439
1497
nx = get_backend (M , C1 , C2 )
1440
1498
1441
- T , logv = entropic_BAPG_fused_gromov_wasserstein (
1499
+ T , logv = BAPG_fused_gromov_wasserstein (
1442
1500
M , C1 , C2 , p , q , loss_fun , epsilon , symmetric , alpha , G0 , max_iter ,
1443
1501
tol , marginal_loss , verbose , log = True )
1444
1502
0 commit comments