Skip to content

Commit 151aa9b

Browse files
committed
doc linear mapping estimation
1 parent 5fe917c commit 151aa9b

File tree

1 file changed

+74
-1
lines changed

1 file changed

+74
-1
lines changed

ot/da.py

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,80 @@ def sinkhorn_lpl1_mm(a,labels_a, b, M, reg, eta=0.1,numItermax = 10,numInnerIter
124124
return transp
125125

126126
def joint_OT_mapping_linear(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):
127-
"""Joint Ot and mapping estimation (uniform weights and )
127+
"""Joint OT and linear mapping estimation as proposed in [8]
128+
129+
The function solves the following optimization problem:
130+
131+
.. math::
132+
\min_{\gamma,L}\quad \|L(X_s) -n_s\gamma X_t\|^2_F + \mu<\gamma,M>_F + \eta \|L -I\|^2_F
133+
134+
s.t. \gamma 1 = a
135+
136+
\gamma^T 1= b
137+
138+
\gamma\geq 0
139+
where :
140+
141+
- M is the (ns,nt) squared euclidean cost matrix between samples in Xs and Xt (scaled by ns)
142+
- :math:`L` is a dxd linear operator that approximates the barycentric mapping
143+
- :math:`I` is the identity matrix (neutral linear mapping)
144+
- a and b are uniform source and target weights
145+
146+
The problem consist in solving jointly an optimal transport matrix
147+
:math:`\gamma` and a linear mapping that fits the barycentric mapping
148+
:math:`n_s\gamma X_t`
149+
150+
The algorithm used for solving the problem is the block coordinate
151+
descent that alternates between updates of G (using conditionnal gradient)
152+
abd the update of L using a classical least square solver.
153+
154+
155+
Parameters
156+
----------
157+
xs : np.ndarray (ns,d)
158+
samples in the source domain
159+
xt : np.ndarray (nt,d)
160+
samples in the target domain
161+
mu: float,optional
162+
Weight for the linear OT loss (>0)
163+
eta: float, optional
164+
Regularization term for the linear mapping L (>0)
165+
bias: bool,optional
166+
Estimate linear mapping with constant bias
167+
numItermax: int, optional
168+
Max number of BCD iterations
169+
stopThr: float, optional
170+
Stop threshold on relative loss decrease (>0)
171+
numInnerItermax: int, optional
172+
Max number of iterations (inner CG solver)
173+
stopInnerThr: float, optional
174+
Stop threshold on error (inner CG solver) (>0)
175+
verbose : bool, optional
176+
Print information along iterations
177+
log : bool, optional
178+
record log if True
179+
180+
181+
Returns
182+
-------
183+
gamma: (ns x nt) ndarray
184+
Optimal transportation matrix for the given parameters
185+
L: (d x d) ndarray
186+
Linear mapping matrix (d+1 x d if bias)
187+
log: dict
188+
log dictionary return only if log==True in parameters
189+
190+
191+
References
192+
----------
193+
194+
.. [8] M. Perrot, N. Courty, R. Flamary, A. Habrard, "Mapping estimation for discrete optimal transport", Neural Information Processing Systems (NIPS), 2016.
195+
196+
See Also
197+
--------
198+
ot.lp.emd : Unregularized OT
199+
ot.optim.cg : General regularized OT
200+
128201
"""
129202

130203
ns,nt,d=xs.shape[0],xt.shape[0],xt.shape[1]

0 commit comments

Comments
 (0)