\(\mathbf{M}\) is the (ns, nt) squared euclidean cost matrix between samples in
\(\mathbf{X_s}\) and \(\mathbf{X_t}\) (scaled by \(n_s\))
\(L\) is a \(n_s \times d\) linear operator on a kernel matrix that
approximates the barycentric mapping
\(\mathbf{a}\) and \(\mathbf{b}\) are uniform source and target weights
The problem consist in solving jointly an optimal transport matrix
\(\gamma\) and the nonlinear mapping that fits the barycentric mapping
\(n_s\gamma \mathbf{X_t}\).
One can also estimate a mapping with constant bias (see supplementary
material of [8]) using the bias optional argument.
The algorithm used for solving the problem is the block coordinate
descent that alternates between updates of \(\mathbf{G}\) (using conditional gradient)
and the update of \(\mathbf{L}\) using a classical kernel least square solver.
Parameters:
xs (array-like (ns,d)) – samples in the source domain
xt (array-like (nt,d)) – samples in the target domain
mu (float,optional) – Weight for the linear OT loss (>0)
eta (float, optional) – Regularization term for the linear mapping L (>0)
kerneltype (str,optional) – kernel used by calling function ot.utils.kernel() (gaussian by default)
\(\mathbf{M}\) is the (ns, nt) squared euclidean cost matrix between samples in
\(\mathbf{X_s}\) and \(\mathbf{X_t}\) (scaled by \(n_s\))
\(L\) is a \(d\times d\) linear operator that approximates the barycentric
mapping
\(\mathbf{I}\) is the identity matrix (neutral linear mapping)
\(\mathbf{a}\) and \(\mathbf{b}\) are uniform source and target weights
The problem consist in solving jointly an optimal transport matrix
\(\gamma\) and a linear mapping that fits the barycentric mapping
\(n_s\gamma \mathbf{X_t}\).
One can also estimate a mapping with constant bias (see supplementary
material of [8]) using the bias optional argument.
The algorithm used for solving the problem is the block coordinate
descent that alternates between updates of \(\mathbf{G}\) (using conditional gradient)
and the update of \(\mathbf{L}\) using a classical least square solver.
Parameters:
xs (array-like (ns,d)) – samples in the source domain
xt (array-like (nt,d)) – samples in the target domain
mu (float,optional) – Weight for the linear OT loss (>0)
eta (float, optional) – Regularization term for the linear mapping L (>0)
bias (bool,optional) – Estimate linear mapping with constant bias
numItermax (int, optional) – Max number of BCD iterations
stopThr (float, optional) – Stop threshold on relative loss decrease (>0)
numInnerItermax (int, optional) – Max number of iterations (inner CG solver)
Computes optimal values and gradients at X for a strongly convex potential \(\varphi\) with Lipschitz gradients
on the partitions defined by X_classes, where \(\varphi\) is optimal such that
\(\nabla \varphi \#\mu \approx \nu\), given samples \(X = x_1, \cdots, x_n \sim \mu\) and
\(V = v_1, \cdots, v_n \sim \nu\). Finding such a potential that has the desired regularity on the
partition \((E_k)_{k \in [K]}\) (given by the classes X_classes) is equivalent to finding optimal values
phi for the \(\varphi(x_i)\) and its gradients \(\nabla \varphi(x_i)\) (variable`G`).
In practice, these optimal values are found by solving the following problem
The constants \(c_1, c_2, c_3\) only depend on strongly_convex_constant and gradient_lipschitz_constant.
The constraint \(\pi \in \Pi(a, b)\) denotes the fact that the matrix \(\pi\) belong to the OT polytope
of marginals a and b. \(I_k\) is the subset of \([n]\) of the i such that \(x_i\) is in the
partition (or class) \(E_k\), i.e. X_classes[i] == k.
This problem is solved by alternating over the variable \(\pi\) and the variables \(\varphi_i, g_i\).
For \(\pi\), the problem is the standard discrete OT problem, and for \(\varphi_i, g_i\), the
problem is a convex QCQP solved using cvxpy (ECOS solver).
Accepts any compatible backend, but will perform the QCQP optimisation on Numpy arrays, and convert back at the end.
Warning
This function requires the CVXPY library
Warning
Accepts any backend but will convert to Numpy then back to the backend.
Parameters:
X (array-like (n, d)) – reference points used to compute the optimal values phi and G
V (array-like (n, d)) – values of the gradients at the reference points X
X_classes (array-like (n,), optional) – classes of the reference points, defaults to a single class
a (array-like (n,), optional) – weights for the reference points X, defaults to uniform
b (array-like (n,), optional) – weights for the target points V, defaults to uniform
strongly_convex_constant (float, optional) – constant for the strong convexity of the input potential phi, defaults to 0.6
gradient_lipschitz_constant (float, optional) – constant for the Lipschitz property of the input gradient G, defaults to 1.4
its (int, optional) – number of iterations, defaults to 100
Smooth and Strongly Convex Nearest Brenier Potentials
ot.mapping.nearest_brenier_potential_predict_bounds(X, phi, G, Y, X_classes=None, Y_classes=None, strongly_convex_constant=0.6, gradient_lipschitz_constant=1.4, log=False, solver=None)[source]
Compute the values of the lower and upper bounding potentials at the input points Y, using the potential optimal
values phi at X and their gradients G at X. The ‘lower’ potential corresponds to the method from [58],
Equation 2, while the bounding property and ‘upper’ potential come from [59], Theorem 3.14 (taking into
account the fact that this theorem’s statement has a min instead of a max, which is a typo). Both potentials are
optimal for the SSNB problem.
If \(I_k\) is the subset of \([n]\) of the i such that \(x_i\) is in the partition (or class)
\(E_k\), for each \(y \in E_k\), this function solves the convex QCQP problems,
respectively for l: ‘lower’ and u: ‘upper’:
\(\mathbf{M}\) is the (ns, nt) squared euclidean cost matrix between samples in
\(\mathbf{X_s}\) and \(\mathbf{X_t}\) (scaled by \(n_s\))
\(L\) is a \(n_s \times d\) linear operator on a kernel matrix that
approximates the barycentric mapping
\(\mathbf{a}\) and \(\mathbf{b}\) are uniform source and target weights
The problem consist in solving jointly an optimal transport matrix
\(\gamma\) and the nonlinear mapping that fits the barycentric mapping
\(n_s\gamma \mathbf{X_t}\).
One can also estimate a mapping with constant bias (see supplementary
material of [8]) using the bias optional argument.
The algorithm used for solving the problem is the block coordinate
descent that alternates between updates of \(\mathbf{G}\) (using conditional gradient)
and the update of \(\mathbf{L}\) using a classical kernel least square solver.
Parameters:
xs (array-like (ns,d)) – samples in the source domain
xt (array-like (nt,d)) – samples in the target domain
mu (float,optional) – Weight for the linear OT loss (>0)
eta (float, optional) – Regularization term for the linear mapping L (>0)
kerneltype (str,optional) – kernel used by calling function ot.utils.kernel() (gaussian by default)
\(\mathbf{M}\) is the (ns, nt) squared euclidean cost matrix between samples in
\(\mathbf{X_s}\) and \(\mathbf{X_t}\) (scaled by \(n_s\))
\(L\) is a \(d\times d\) linear operator that approximates the barycentric
mapping
\(\mathbf{I}\) is the identity matrix (neutral linear mapping)
\(\mathbf{a}\) and \(\mathbf{b}\) are uniform source and target weights
The problem consist in solving jointly an optimal transport matrix
\(\gamma\) and a linear mapping that fits the barycentric mapping
\(n_s\gamma \mathbf{X_t}\).
One can also estimate a mapping with constant bias (see supplementary
material of [8]) using the bias optional argument.
The algorithm used for solving the problem is the block coordinate
descent that alternates between updates of \(\mathbf{G}\) (using conditional gradient)
and the update of \(\mathbf{L}\) using a classical least square solver.
Parameters:
xs (array-like (ns,d)) – samples in the source domain
xt (array-like (nt,d)) – samples in the target domain
mu (float,optional) – Weight for the linear OT loss (>0)
eta (float, optional) – Regularization term for the linear mapping L (>0)
bias (bool,optional) – Estimate linear mapping with constant bias
numItermax (int, optional) – Max number of BCD iterations
stopThr (float, optional) – Stop threshold on relative loss decrease (>0)
numInnerItermax (int, optional) – Max number of iterations (inner CG solver)
Computes optimal values and gradients at X for a strongly convex potential \(\varphi\) with Lipschitz gradients
on the partitions defined by X_classes, where \(\varphi\) is optimal such that
\(\nabla \varphi \#\mu \approx \nu\), given samples \(X = x_1, \cdots, x_n \sim \mu\) and
\(V = v_1, \cdots, v_n \sim \nu\). Finding such a potential that has the desired regularity on the
partition \((E_k)_{k \in [K]}\) (given by the classes X_classes) is equivalent to finding optimal values
phi for the \(\varphi(x_i)\) and its gradients \(\nabla \varphi(x_i)\) (variable`G`).
In practice, these optimal values are found by solving the following problem
The constants \(c_1, c_2, c_3\) only depend on strongly_convex_constant and gradient_lipschitz_constant.
The constraint \(\pi \in \Pi(a, b)\) denotes the fact that the matrix \(\pi\) belong to the OT polytope
of marginals a and b. \(I_k\) is the subset of \([n]\) of the i such that \(x_i\) is in the
partition (or class) \(E_k\), i.e. X_classes[i] == k.
This problem is solved by alternating over the variable \(\pi\) and the variables \(\varphi_i, g_i\).
For \(\pi\), the problem is the standard discrete OT problem, and for \(\varphi_i, g_i\), the
problem is a convex QCQP solved using cvxpy (ECOS solver).
Accepts any compatible backend, but will perform the QCQP optimisation on Numpy arrays, and convert back at the end.
Warning
This function requires the CVXPY library
Warning
Accepts any backend but will convert to Numpy then back to the backend.
Parameters:
X (array-like (n, d)) – reference points used to compute the optimal values phi and G
V (array-like (n, d)) – values of the gradients at the reference points X
X_classes (array-like (n,), optional) – classes of the reference points, defaults to a single class
a (array-like (n,), optional) – weights for the reference points X, defaults to uniform
b (array-like (n,), optional) – weights for the target points V, defaults to uniform
strongly_convex_constant (float, optional) – constant for the strong convexity of the input potential phi, defaults to 0.6
gradient_lipschitz_constant (float, optional) – constant for the Lipschitz property of the input gradient G, defaults to 1.4
its (int, optional) – number of iterations, defaults to 100
ot.mapping.nearest_brenier_potential_predict_bounds(X, phi, G, Y, X_classes=None, Y_classes=None, strongly_convex_constant=0.6, gradient_lipschitz_constant=1.4, log=False, solver=None)[source]
Compute the values of the lower and upper bounding potentials at the input points Y, using the potential optimal
values phi at X and their gradients G at X. The ‘lower’ potential corresponds to the method from [58],
Equation 2, while the bounding property and ‘upper’ potential come from [59], Theorem 3.14 (taking into
account the fact that this theorem’s statement has a min instead of a max, which is a typo). Both potentials are
optimal for the SSNB problem.
If \(I_k\) is the subset of \([n]\) of the i such that \(x_i\) is in the partition (or class)
\(E_k\), for each \(y \in E_k\), this function solves the convex QCQP problems,
respectively for l: ‘lower’ and u: ‘upper’: