MCPcopy Create free account
hub / github.com/PythonOT/POT / partial_cg

Function partial_cg

ot/optim.py:669–805  ·  view source on GitHub ↗

r""" Solve the general regularized partial 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.

(
    a,
    b,
    a_extended,
    b_extended,
    M,
    reg,
    f,
    df,
    G0=None,
    line_search=line_search_armijo,
    numItermax=200,
    stopThr=1e-9,
    stopThr2=1e-9,
    warn=True,
    verbose=False,
    log=False,
    **kwargs,
)

Source from the content-addressed store, hash-verified

667
668
669def partial_cg(
670 a,
671 b,
672 a_extended,
673 b_extended,
674 M,
675 reg,
676 f,
677 df,
678 G0=None,
679 line_search=line_search_armijo,
680 numItermax=200,
681 stopThr=1e-9,
682 stopThr2=1e-9,
683 warn=True,
684 verbose=False,
685 log=False,
686 **kwargs,
687):
688 r"""
689 Solve the general regularized partial OT problem with conditional gradient
690
691 The function solves the following optimization problem:
692
693 .. math::
694 \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F +
695 \mathrm{reg} \cdot f(\gamma)
696
697 s.t. \ \gamma \mathbf{1} &= \mathbf{a}
698
699 \gamma \mathbf{1} &= \mathbf{b}
700
701 \mathbf{1}^T \gamma^T \mathbf{1} = m &\leq \min\{\|\mathbf{p}\|_1, \|\mathbf{q}\|_1\}
702
703 \gamma &\geq 0
704
705 where :
706
707 - :math:`\mathbf{M}` is the (`ns`, `nt`) metric cost matrix
708 - :math:`f` is the regularization term (and `df` is its gradient)
709 - :math:`\mathbf{a}` and :math:`\mathbf{b}` are source and target weights
710 - `m` is the amount of mass to be transported
711
712 The algorithm used for solving the problem is conditional gradient as discussed in :ref:`[1] <references-cg>`
713
714 Parameters
715 ----------
716 a : array-like, shape (ns,)
717 samples weights in the source domain
718 b : array-like, shape (nt,)
719 currently estimated samples weights in the target domain
720 a_extended : array-like, shape (ns + nb_dummies,)
721 samples weights in the source domain with added dummy nodes
722 b_extended : array-like, shape (nt + nb_dummies,)
723 currently estimated samples weights in the target domain with added dummy nodes
724 M : array-like, shape (ns, nt)
725 loss matrix
726 reg : float

Callers 2

Calls 1

Tested by

no test coverage detected