r"""Solve the discrete (Fused) Gromov-Wasserstein and return :any:`OTResult` object The function solves the following optimization problem: .. math:: \min_{\mathbf{T}\geq 0} \quad (1 - \alpha) \langle \mathbf{T}, \mathbf{M} \rangle_F + \alpha \sum_{i,j,k,l} L(\mathbf{C_1}_{
(
Ca,
Cb,
M=None,
a=None,
b=None,
loss="L2",
symmetric=None,
alpha=0.5,
reg=None,
reg_type="entropy",
unbalanced=None,
unbalanced_type="KL",
n_threads=1,
method=None,
max_iter=None,
plan_init=None,
tol=None,
verbose=False,
)
| 602 | |
| 603 | |
| 604 | def solve_gromov( |
| 605 | Ca, |
| 606 | Cb, |
| 607 | M=None, |
| 608 | a=None, |
| 609 | b=None, |
| 610 | loss="L2", |
| 611 | symmetric=None, |
| 612 | alpha=0.5, |
| 613 | reg=None, |
| 614 | reg_type="entropy", |
| 615 | unbalanced=None, |
| 616 | unbalanced_type="KL", |
| 617 | n_threads=1, |
| 618 | method=None, |
| 619 | max_iter=None, |
| 620 | plan_init=None, |
| 621 | tol=None, |
| 622 | verbose=False, |
| 623 | ): |
| 624 | r"""Solve the discrete (Fused) Gromov-Wasserstein and return :any:`OTResult` object |
| 625 | |
| 626 | The function solves the following optimization problem: |
| 627 | |
| 628 | .. math:: |
| 629 | \min_{\mathbf{T}\geq 0} \quad (1 - \alpha) \langle \mathbf{T}, \mathbf{M} \rangle_F + |
| 630 | \alpha \sum_{i,j,k,l} L(\mathbf{C_1}_{i,k}, \mathbf{C_2}_{j,l}) \mathbf{T}_{i,j} \mathbf{T}_{k,l} + \lambda_r R(\mathbf{T}) + \lambda_u U(\mathbf{T}\mathbf{1},\mathbf{a}) + \lambda_u U(\mathbf{T}^T\mathbf{1},\mathbf{b}) |
| 631 | |
| 632 | The regularization is selected with `reg` (:math:`\lambda_r`) and |
| 633 | `reg_type`. By default ``reg=None`` and there is no regularization. The |
| 634 | unbalanced marginal penalization can be selected with `unbalanced` |
| 635 | (:math:`\lambda_u`) and `unbalanced_type`. By default ``unbalanced=None`` |
| 636 | and the function solves the exact optimal transport problem (respecting the |
| 637 | marginals). |
| 638 | |
| 639 | Parameters |
| 640 | ---------- |
| 641 | Ca : array-like, shape (dim_a, dim_a) |
| 642 | Cost matrix in the source domain |
| 643 | Cb : array-like, shape (dim_b, dim_b) |
| 644 | Cost matrix in the target domain |
| 645 | M : array-like, shape (dim_a, dim_b), optional |
| 646 | Linear cost matrix for Fused Gromov-Wasserstein (default is None). |
| 647 | a : array-like, shape (dim_a,), optional |
| 648 | Samples weights in the source domain (default is uniform) |
| 649 | b : array-like, shape (dim_b,), optional |
| 650 | Samples weights in the source domain (default is uniform) |
| 651 | loss : str, optional |
| 652 | Type of loss function, either ``"L2"`` or ``"KL"``, by default ``"L2"`` |
| 653 | symmetric : bool, optional |
| 654 | Use symmetric version of the Gromov-Wasserstein problem, by default None |
| 655 | tests whether the matrices are symmetric or True/False to avoid the test. |
| 656 | reg : float, optional |
| 657 | Regularization weight :math:`\lambda_r`, by default None (no reg., exact |
| 658 | OT) |
| 659 | reg_type : str, optional |
| 660 | Type of regularization :math:`R`, by default "entropy" (only used when |
| 661 | ``reg!=None``) |