r""" Solve the general regularized OT problem with the generalized conditional gradient The function solves the following optimization problem: .. math:: \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F + \mathrm{reg_1}\cdot\Omega(\gamma
(
a,
b,
M,
reg1,
reg2,
f,
df,
G0=None,
numItermax=10,
numInnerItermax=200,
stopThr=1e-9,
stopThr2=1e-9,
verbose=False,
log=False,
**kwargs,
)
| 806 | |
| 807 | |
| 808 | def gcg( |
| 809 | a, |
| 810 | b, |
| 811 | M, |
| 812 | reg1, |
| 813 | reg2, |
| 814 | f, |
| 815 | df, |
| 816 | G0=None, |
| 817 | numItermax=10, |
| 818 | numInnerItermax=200, |
| 819 | stopThr=1e-9, |
| 820 | stopThr2=1e-9, |
| 821 | verbose=False, |
| 822 | log=False, |
| 823 | **kwargs, |
| 824 | ): |
| 825 | r""" |
| 826 | Solve the general regularized OT problem with the generalized conditional gradient |
| 827 | |
| 828 | The function solves the following optimization problem: |
| 829 | |
| 830 | .. math:: |
| 831 | \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F + |
| 832 | \mathrm{reg_1}\cdot\Omega(\gamma) + \mathrm{reg_2}\cdot f(\gamma) |
| 833 | |
| 834 | s.t. \ \gamma \mathbf{1} &= \mathbf{a} |
| 835 | |
| 836 | \gamma^T \mathbf{1} &= \mathbf{b} |
| 837 | |
| 838 | \gamma &\geq 0 |
| 839 | |
| 840 | where : |
| 841 | |
| 842 | - :math:`\mathbf{M}` is the (`ns`, `nt`) metric cost matrix |
| 843 | - :math:`\Omega` is the entropic regularization term :math:`\Omega(\gamma)=\sum_{i,j} \gamma_{i,j}\log(\gamma_{i,j})` |
| 844 | - :math:`f` is the regularization term (and `df` is its gradient) |
| 845 | - :math:`\mathbf{a}` and :math:`\mathbf{b}` are source and target weights (sum to 1) |
| 846 | |
| 847 | The algorithm used for solving the problem is the generalized conditional gradient as discussed in :ref:`[5, 7] <references-gcg>` |
| 848 | |
| 849 | |
| 850 | Parameters |
| 851 | ---------- |
| 852 | a : array-like, shape (ns,) |
| 853 | samples weights in the source domain |
| 854 | b : array-like, (nt,) |
| 855 | samples in the target domain |
| 856 | M : array-like, shape (ns, nt) |
| 857 | loss matrix |
| 858 | reg1 : float |
| 859 | Entropic Regularization term >0 |
| 860 | reg2 : float |
| 861 | Second Regularization term >0 |
| 862 | G0 : array-like, shape (ns, nt), optional |
| 863 | initial guess (default is indep joint density) |
| 864 | numItermax : int, optional |
| 865 | Max number of iterations |
no test coverage detected