r""" Solve the general regularized OT problem with conditional gradient The function solves the following optimization problem: .. math:: \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F + \mathrm{reg} \cdot f(\gamma) s.t. \ \ga
(
a,
b,
M,
reg,
f,
df,
G0=None,
line_search=None,
numItermax=200,
numItermaxEmd=100000,
stopThr=1e-9,
stopThr2=1e-9,
verbose=False,
log=False,
nx=None,
**kwargs,
)
| 410 | |
| 411 | |
| 412 | def cg( |
| 413 | a, |
| 414 | b, |
| 415 | M, |
| 416 | reg, |
| 417 | f, |
| 418 | df, |
| 419 | G0=None, |
| 420 | line_search=None, |
| 421 | numItermax=200, |
| 422 | numItermaxEmd=100000, |
| 423 | stopThr=1e-9, |
| 424 | stopThr2=1e-9, |
| 425 | verbose=False, |
| 426 | log=False, |
| 427 | nx=None, |
| 428 | **kwargs, |
| 429 | ): |
| 430 | r""" |
| 431 | Solve the general regularized OT problem with conditional gradient |
| 432 | |
| 433 | The function solves the following optimization problem: |
| 434 | |
| 435 | .. math:: |
| 436 | \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F + |
| 437 | \mathrm{reg} \cdot f(\gamma) |
| 438 | |
| 439 | s.t. \ \gamma \mathbf{1} &= \mathbf{a} |
| 440 | |
| 441 | \gamma^T \mathbf{1} &= \mathbf{b} |
| 442 | |
| 443 | \gamma &\geq 0 |
| 444 | |
| 445 | where : |
| 446 | |
| 447 | - :math:`\mathbf{M}` is the (`ns`, `nt`) metric cost matrix |
| 448 | - :math:`f` is the regularization term (and `df` is its gradient) |
| 449 | - :math:`\mathbf{a}` and :math:`\mathbf{b}` are source and target weights (sum to 1) |
| 450 | |
| 451 | The algorithm used for solving the problem is conditional gradient as discussed in :ref:`[1] <references-cg>` |
| 452 | |
| 453 | |
| 454 | Parameters |
| 455 | ---------- |
| 456 | a : array-like, shape (ns,) |
| 457 | samples weights in the source domain |
| 458 | b : array-like, shape (nt,) |
| 459 | samples in the target domain |
| 460 | M : array-like, shape (ns, nt) |
| 461 | loss matrix |
| 462 | reg : float |
| 463 | Regularization term >0 |
| 464 | G0 : array-like, shape (ns,nt), optional |
| 465 | initial guess (default is indep joint density) |
| 466 | line_search: function, |
| 467 | Function to find the optimal step. |
| 468 | Default is None and calls a wrapper to line_search_armijo. |
| 469 | numItermax : int, optional |
no test coverage detected