summaryrefslogtreecommitdiff
path: root/ot/gromov
diff options
context:
space:
mode:
Diffstat (limited to 'ot/gromov')
-rw-r--r--ot/gromov/_bregman.py6
-rw-r--r--ot/gromov/_dictionary.py10
-rw-r--r--ot/gromov/_gw.py17
-rw-r--r--ot/gromov/_semirelaxed.py15
-rw-r--r--ot/gromov/_utils.py8
5 files changed, 31 insertions, 25 deletions
diff --git a/ot/gromov/_bregman.py b/ot/gromov/_bregman.py
index b0cccfb..aa25f1f 100644
--- a/ot/gromov/_bregman.py
+++ b/ot/gromov/_bregman.py
@@ -69,7 +69,7 @@ def entropic_gromov_wasserstein(C1, C2, p, q, loss_fun, epsilon, symmetric=None,
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
G0: array-like, shape (ns,nt), optional
If None the initial transport plan of the solver is pq^T.
Otherwise G0 must satisfy marginal constraints and will be used as initial transport of the solver.
@@ -152,7 +152,7 @@ def entropic_gromov_wasserstein(C1, C2, p, q, loss_fun, epsilon, symmetric=None,
def entropic_gromov_wasserstein2(C1, C2, p, q, loss_fun, epsilon, symmetric=None, G0=None,
max_iter=1000, tol=1e-9, verbose=False, log=False):
r"""
- Returns the entropic gromov-wasserstein discrepancy between the two measured similarity matrices :math:`(\mathbf{C_1}, \mathbf{p})` and :math:`(\mathbf{C_2}, \mathbf{q})`
+ Returns the entropic Gromov-Wasserstein discrepancy between the two measured similarity matrices :math:`(\mathbf{C_1}, \mathbf{p})` and :math:`(\mathbf{C_2}, \mathbf{q})`
The function solves the following optimization problem:
@@ -194,7 +194,7 @@ def entropic_gromov_wasserstein2(C1, C2, p, q, loss_fun, epsilon, symmetric=None
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
G0: array-like, shape (ns,nt), optional
If None the initial transport plan of the solver is pq^T.
Otherwise G0 must satisfy marginal constraints and will be used as initial transport of the solver.
diff --git a/ot/gromov/_dictionary.py b/ot/gromov/_dictionary.py
index 5b32671..0d618d1 100644
--- a/ot/gromov/_dictionary.py
+++ b/ot/gromov/_dictionary.py
@@ -148,7 +148,7 @@ def gromov_wasserstein_dictionary_learning(Cs, D, nt, reg=0., ps=None, q=None, e
Ts = [None] * batch_size
for batch_idx, C_idx in enumerate(batch):
- # BCD solver for Gromov-Wassersteisn linear unmixing used independently on each structure of the sampled batch
+ # BCD solver for Gromov-Wasserstein linear unmixing used independently on each structure of the sampled batch
unmixings[batch_idx], Cs_embedded[batch_idx], Ts[batch_idx], current_loss = gromov_wasserstein_linear_unmixing(
Cs[C_idx], Cdict, reg=reg, p=ps[C_idx], q=q, tol_outer=tol_outer, tol_inner=tol_inner,
max_iter_outer=max_iter_outer, max_iter_inner=max_iter_inner, symmetric=symmetric, **kwargs
@@ -252,7 +252,7 @@ def gromov_wasserstein_linear_unmixing(C, Cdict, reg=0., p=None, q=None, tol_out
Returns
-------
w: array-like, shape (D,)
- gromov-wasserstein linear unmixing of :math:`(\mathbf{C},\mathbf{p})` onto the span of the dictionary.
+ Gromov-Wasserstein linear unmixing of :math:`(\mathbf{C},\mathbf{p})` onto the span of the dictionary.
Cembedded: array-like, shape (nt,nt)
embedded structure of :math:`(\mathbf{C},\mathbf{p})` onto the dictionary, :math:`\sum_d w_d\mathbf{C_{dict}[d]}`.
T: array-like (ns, nt)
@@ -559,7 +559,7 @@ def fused_gromov_wasserstein_dictionary_learning(Cs, Ys, D, nt, alpha, reg=0., p
Feature matrices composing the dictionary.
The dictionary leading to the best loss over an epoch is saved and returned.
log: dict
- If use_log is True, contains loss evolutions by batches and epoches.
+ If use_log is True, contains loss evolutions by batches and epochs.
References
-------
.. [38] C. Vincent-Cuaz, T. Vayer, R. Flamary, M. Corneli, N. Courty, Online
@@ -634,7 +634,7 @@ def fused_gromov_wasserstein_dictionary_learning(Cs, Ys, D, nt, alpha, reg=0., p
Ts = [None] * batch_size
for batch_idx, C_idx in enumerate(batch):
- # BCD solver for Gromov-Wassersteisn linear unmixing used independently on each structure of the sampled batch
+ # BCD solver for Gromov-Wasserstein linear unmixing used independently on each structure of the sampled batch
unmixings[batch_idx], Cs_embedded[batch_idx], Ys_embedded[batch_idx], Ts[batch_idx], current_loss = fused_gromov_wasserstein_linear_unmixing(
Cs[C_idx], Ys[C_idx], Cdict, Ydict, alpha, reg=reg, p=ps[C_idx], q=q,
tol_outer=tol_outer, tol_inner=tol_inner, max_iter_outer=max_iter_outer, max_iter_inner=max_iter_inner, symmetric=symmetric, **kwargs
@@ -736,7 +736,7 @@ def fused_gromov_wasserstein_linear_unmixing(C, Y, Cdict, Ydict, alpha, reg=0.,
Returns
-------
w: array-like, shape (D,)
- fused gromov-wasserstein linear unmixing of (C,Y,p) onto the span of the dictionary.
+ fused Gromov-Wasserstein linear unmixing of (C,Y,p) onto the span of the dictionary.
Cembedded: array-like, shape (nt,nt)
embedded structure of :math:`(\mathbf{C},\mathbf{Y}, \mathbf{p})` onto the dictionary, :math:`\sum_d w_d\mathbf{C_{dict}[d]}`.
Yembedded: array-like, shape (nt,d)
diff --git a/ot/gromov/_gw.py b/ot/gromov/_gw.py
index bc4719d..cdfa9a3 100644
--- a/ot/gromov/_gw.py
+++ b/ot/gromov/_gw.py
@@ -26,7 +26,7 @@ from ._utils import update_square_loss, update_kl_loss
def gromov_wasserstein(C1, C2, p, q, loss_fun='square_loss', symmetric=None, log=False, armijo=False, G0=None,
max_iter=1e4, tol_rel=1e-9, tol_abs=1e-9, **kwargs):
r"""
- Returns the gromov-wasserstein transport between :math:`(\mathbf{C_1}, \mathbf{p})` and :math:`(\mathbf{C_2}, \mathbf{q})`
+ Returns the Gromov-Wasserstein transport between :math:`(\mathbf{C_1}, \mathbf{p})` and :math:`(\mathbf{C_2}, \mathbf{q})`
The function solves the following optimization problem:
@@ -39,6 +39,7 @@ def gromov_wasserstein(C1, C2, p, q, loss_fun='square_loss', symmetric=None, log
\mathbf{\gamma}^T \mathbf{1} &= \mathbf{q}
\mathbf{\gamma} &\geq 0
+
Where :
- :math:`\mathbf{C_1}`: Metric cost matrix in the source space
@@ -68,7 +69,7 @@ def gromov_wasserstein(C1, C2, p, q, loss_fun='square_loss', symmetric=None, log
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
verbose : bool, optional
Print information along iterations
log : bool, optional
@@ -170,7 +171,7 @@ def gromov_wasserstein(C1, C2, p, q, loss_fun='square_loss', symmetric=None, log
def gromov_wasserstein2(C1, C2, p, q, loss_fun='square_loss', symmetric=None, log=False, armijo=False, G0=None,
max_iter=1e4, tol_rel=1e-9, tol_abs=1e-9, **kwargs):
r"""
- Returns the gromov-wasserstein discrepancy between :math:`(\mathbf{C_1}, \mathbf{p})` and :math:`(\mathbf{C_2}, \mathbf{q})`
+ Returns the Gromov-Wasserstein discrepancy between :math:`(\mathbf{C_1}, \mathbf{p})` and :math:`(\mathbf{C_2}, \mathbf{q})`
The function solves the following optimization problem:
@@ -183,6 +184,7 @@ def gromov_wasserstein2(C1, C2, p, q, loss_fun='square_loss', symmetric=None, lo
\mathbf{\gamma}^T \mathbf{1} &= \mathbf{q}
\mathbf{\gamma} &\geq 0
+
Where :
- :math:`\mathbf{C_1}`: Metric cost matrix in the source space
@@ -216,7 +218,7 @@ def gromov_wasserstein2(C1, C2, p, q, loss_fun='square_loss', symmetric=None, lo
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
verbose : bool, optional
Print information along iterations
log : bool, optional
@@ -241,7 +243,7 @@ def gromov_wasserstein2(C1, C2, p, q, loss_fun='square_loss', symmetric=None, lo
gw_dist : float
Gromov-Wasserstein distance
log : dict
- convergence information and Coupling marix
+ convergence information and Coupling matrix
References
----------
@@ -310,6 +312,7 @@ def fused_gromov_wasserstein(M, C1, C2, p, q, loss_fun='square_loss', symmetric=
which can lead to copy overhead on GPU arrays.
.. note:: All computations in the conjugate gradient solver are done with
numpy to limit memory overhead.
+
The algorithm used for solving the problem is conditional gradient as discussed in :ref:`[24] <references-fused-gromov-wasserstein>`
Parameters
@@ -329,7 +332,7 @@ def fused_gromov_wasserstein(M, C1, C2, p, q, loss_fun='square_loss', symmetric=
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
alpha : float, optional
Trade-off parameter (0 < alpha < 1)
armijo : bool, optional
@@ -503,7 +506,7 @@ def fused_gromov_wasserstein2(M, C1, C2, p, q, loss_fun='square_loss', symmetric
Returns
-------
fgw-distance : float
- Fused gromov wasserstein distance for the given parameters.
+ Fused Gromov-Wasserstein distance for the given parameters.
log : dict
Log dictionary return only if log==True in parameters.
diff --git a/ot/gromov/_semirelaxed.py b/ot/gromov/_semirelaxed.py
index 638bb1c..cb2bf28 100644
--- a/ot/gromov/_semirelaxed.py
+++ b/ot/gromov/_semirelaxed.py
@@ -21,7 +21,7 @@ from ._utils import init_matrix_semirelaxed, gwloss, gwggrad
def semirelaxed_gromov_wasserstein(C1, C2, p, loss_fun='square_loss', symmetric=None, log=False, G0=None,
max_iter=1e4, tol_rel=1e-9, tol_abs=1e-9, **kwargs):
r"""
- Returns the semi-relaxed gromov-wasserstein divergence transport from :math:`(\mathbf{C_1}, \mathbf{p})` to :math:`\mathbf{C_2}`
+ Returns the semi-relaxed Gromov-Wasserstein divergence transport from :math:`(\mathbf{C_1}, \mathbf{p})` to :math:`\mathbf{C_2}`
The function solves the following optimization problem:
@@ -32,6 +32,7 @@ def semirelaxed_gromov_wasserstein(C1, C2, p, loss_fun='square_loss', symmetric=
s.t. \ \mathbf{\gamma} \mathbf{1} &= \mathbf{p}
\mathbf{\gamma} &\geq 0
+
Where :
- :math:`\mathbf{C_1}`: Metric cost matrix in the source space
@@ -58,7 +59,7 @@ def semirelaxed_gromov_wasserstein(C1, C2, p, loss_fun='square_loss', symmetric=
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
verbose : bool, optional
Print information along iterations
log : bool, optional
@@ -156,6 +157,7 @@ def semirelaxed_gromov_wasserstein2(C1, C2, p, loss_fun='square_loss', symmetric
s.t. \ \mathbf{\gamma} \mathbf{1} &= \mathbf{p}
\mathbf{\gamma} &\geq 0
+
Where :
- :math:`\mathbf{C_1}`: Metric cost matrix in the source space
@@ -166,6 +168,7 @@ def semirelaxed_gromov_wasserstein2(C1, C2, p, loss_fun='square_loss', symmetric
Note that when using backends, this loss function is differentiable wrt the
matrices (C1, C2) but not yet for the weights p.
+
.. note:: This function is backend-compatible and will work on arrays
from all compatible backends. However all the steps in the conditional
gradient are not differentiable.
@@ -184,7 +187,7 @@ def semirelaxed_gromov_wasserstein2(C1, C2, p, loss_fun='square_loss', symmetric
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
verbose : bool, optional
Print information along iterations
log : bool, optional
@@ -278,7 +281,7 @@ def semirelaxed_fused_gromov_wasserstein(M, C1, C2, p, loss_fun='square_loss', s
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
alpha : float, optional
Trade-off parameter (0 < alpha < 1)
G0: array-like, shape (ns,nt), optional
@@ -415,7 +418,7 @@ def semirelaxed_fused_gromov_wasserstein2(M, C1, C2, p, loss_fun='square_loss',
symmetric : bool, optional
Either C1 and C2 are to be assumed symmetric or not.
If let to its default None value, a symmetry test will be conducted.
- Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymetric).
+ Else if set to True (resp. False), C1 and C2 will be assumed symmetric (resp. asymmetric).
alpha : float, optional
Trade-off parameter (0 < alpha < 1)
G0: array-like, shape (ns,nt), optional
@@ -435,7 +438,7 @@ def semirelaxed_fused_gromov_wasserstein2(M, C1, C2, p, loss_fun='square_loss',
Returns
-------
srfgw-divergence : float
- Semi-relaxed Fused gromov wasserstein divergence for the given parameters.
+ Semi-relaxed Fused Gromov-Wasserstein divergence for the given parameters.
log : dict
Log dictionary return only if log==True in parameters.
diff --git a/ot/gromov/_utils.py b/ot/gromov/_utils.py
index e842250..ef8cd88 100644
--- a/ot/gromov/_utils.py
+++ b/ot/gromov/_utils.py
@@ -20,7 +20,7 @@ def init_matrix(C1, C2, p, q, loss_fun='square_loss', nx=None):
r"""Return loss matrices and tensors for Gromov-Wasserstein fast computation
Returns the value of :math:`\mathcal{L}(\mathbf{C_1}, \mathbf{C_2}) \otimes \mathbf{T}` with the
- selected loss function as the loss function of Gromow-Wasserstein discrepancy.
+ selected loss function as the loss function of Gromov-Wasserstein discrepancy.
The matrices are computed as described in Proposition 1 in :ref:`[12] <references-init-matrix>`
@@ -195,7 +195,7 @@ def gwloss(constC, hC1, hC2, T, nx=None):
Returns
-------
loss : float
- Gromov Wasserstein loss
+ Gromov-Wasserstein loss
.. _references-gwloss:
@@ -235,7 +235,7 @@ def gwggrad(constC, hC1, hC2, T, nx=None):
Returns
-------
grad : array-like, shape (`ns`, `nt`)
- Gromov Wasserstein gradient
+ Gromov-Wasserstein gradient
.. _references-gwggrad:
@@ -328,7 +328,7 @@ def init_matrix_semirelaxed(C1, C2, p, loss_fun='square_loss', nx=None):
r"""Return loss matrices and tensors for semi-relaxed Gromov-Wasserstein fast computation
Returns the value of :math:`\mathcal{L}(\mathbf{C_1}, \mathbf{C_2}) \otimes \mathbf{T}` with the
- selected loss function as the loss function of semi-relaxed Gromow-Wasserstein discrepancy.
+ selected loss function as the loss function of semi-relaxed Gromov-Wasserstein discrepancy.
The matrices are computed as described in Proposition 1 in :ref:`[12] <references-init-matrix>`
and adapted to the semi-relaxed problem where the second marginal is not a constant anymore.