r"""Joint OT and linear mapping estimation as proposed in :ref:`[8] `. The function solves the following optimization problem: .. math:: \min_{\gamma,L}\quad \|L(\mathbf{X_s}) - n_s\gamma \mathbf{X_t} \|^2_F + \mu \langle \gamma, \m
(
xs,
xt,
mu=1,
eta=0.001,
bias=False,
verbose=False,
verbose2=False,
numItermax=100,
numInnerItermax=10,
stopInnerThr=1e-6,
stopThr=1e-5,
log=False,
**kwargs,
)
| 422 | |
| 423 | |
| 424 | def joint_OT_mapping_linear( |
| 425 | xs, |
| 426 | xt, |
| 427 | mu=1, |
| 428 | eta=0.001, |
| 429 | bias=False, |
| 430 | verbose=False, |
| 431 | verbose2=False, |
| 432 | numItermax=100, |
| 433 | numInnerItermax=10, |
| 434 | stopInnerThr=1e-6, |
| 435 | stopThr=1e-5, |
| 436 | log=False, |
| 437 | **kwargs, |
| 438 | ): |
| 439 | r"""Joint OT and linear mapping estimation as proposed in |
| 440 | :ref:`[8] <references-joint-OT-mapping-linear>`. |
| 441 | |
| 442 | The function solves the following optimization problem: |
| 443 | |
| 444 | .. math:: |
| 445 | \min_{\gamma,L}\quad \|L(\mathbf{X_s}) - n_s\gamma \mathbf{X_t} \|^2_F + |
| 446 | \mu \langle \gamma, \mathbf{M} \rangle_F + \eta \|L - \mathbf{I}\|^2_F |
| 447 | |
| 448 | s.t. \ \gamma \mathbf{1} = \mathbf{a} |
| 449 | |
| 450 | \gamma^T \mathbf{1} = \mathbf{b} |
| 451 | |
| 452 | \gamma \geq 0 |
| 453 | |
| 454 | where : |
| 455 | |
| 456 | - :math:`\mathbf{M}` is the (`ns`, `nt`) squared euclidean cost matrix between samples in |
| 457 | :math:`\mathbf{X_s}` and :math:`\mathbf{X_t}` (scaled by :math:`n_s`) |
| 458 | - :math:`L` is a :math:`d\times d` linear operator that approximates the barycentric |
| 459 | mapping |
| 460 | - :math:`\mathbf{I}` is the identity matrix (neutral linear mapping) |
| 461 | - :math:`\mathbf{a}` and :math:`\mathbf{b}` are uniform source and target weights |
| 462 | |
| 463 | The problem consist in solving jointly an optimal transport matrix |
| 464 | :math:`\gamma` and a linear mapping that fits the barycentric mapping |
| 465 | :math:`n_s\gamma \mathbf{X_t}`. |
| 466 | |
| 467 | One can also estimate a mapping with constant bias (see supplementary |
| 468 | material of :ref:`[8] <references-joint-OT-mapping-linear>`) using the bias optional argument. |
| 469 | |
| 470 | The algorithm used for solving the problem is the block coordinate |
| 471 | descent that alternates between updates of :math:`\mathbf{G}` (using conditional gradient) |
| 472 | and the update of :math:`\mathbf{L}` using a classical least square solver. |
| 473 | |
| 474 | |
| 475 | Parameters |
| 476 | ---------- |
| 477 | xs : array-like (ns,d) |
| 478 | samples in the source domain |
| 479 | xt : array-like (nt,d) |
| 480 | samples in the target domain |
| 481 | mu : float,optional |
no test coverage detected