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@@@@@@@@@#@#@@@88$$$W#933404?=--@@@@@#@@@@@#@@@@@
@@#@@@@@#@#@@@@@@@#@@@@@#@@@#@731a279W713@0:,-+@@@@@@@@@#@@@@@@@
#@#@@@@@@@#@@@@@@@#@@@@@@@@@@@$54?c258379762479#@@@@@@@@#@#@@@@@
@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@747c;27a98@9#@@@@@@@@@@@@@@@@@@@@
#@#@@@@@#@@@@@@@@@@@@@@@#@@@@@@746c;c;!5553#@@@@@@@@@@@@#@@@@@@@
@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@887?!-==+cb+9@@@@@@@@@@@@#@@@@@@@
WWWWWWWWWWWWWWWWWWWWW######@@@@9872:+-._....@@@@@@#@@@@@#@@@@@@@
$$$$$$$$99999999999999$$$$$$$$W977?;:=-_    _@@@@@#@@@@@@@#@@@@@
8888877777777777777777777778888577cb;:+,     ?####@@@###@@@@@@@@
776666665555555555555555555555677??abbc+,_  _=$9$$WWW##@@@#@@@@@
5555544443344333333333333333357711!aaab;=,.,=;667788899$$WW###@@
443333333877776311111111111167442??aaabc;++:;2444555667778899$$$
2322222167777777766640??000088831?!!bbbbc;cc!1222223344455566778
21111100026666666666665?!!!!!0775320?!????122?000000112223334455
100000??????035555555555551aaa778898777775a-aa!!!!????0001112223
000?????!!!!!aaaa0444455454457861?bc:+=-,,-+:bbbbaaaa!!!!????001
???!?!!!!!aaaaabbbbb444444450?!abccc:+-,,,--,,=ccbbbbbaaaa!!!???
???!!!!!aaaaaabbbbbcb!443334?b;:++=--,,..__    ;;;cccccbbbbbaaa!
??!!!!aaaaabbbbbccc;c;a233373?ac:=-,.        .;;;;;;;;;;;ccbbba
?!!!!aaaaabbbbbcccc;;;;;3358852?b;+=-,__   _,+?+:::::;;;;;;;;ccc
!!!!aaaaabbbbbcccc;;;;;;;b337987420!abbc;cb!15c.+:::::::::;;;;;;
!!!!aaaaabbbbbcccc;;;;;;;;:2!cba0467765542b:, _c+++++++::::::;;;
!!!!aaaaaabbbbcccc;;;;;;;;:cbaa!a;==,..___,=cbb:++++++++::::::::
!!!!!aaaaabbbbbcccc;;;;;;;;bbcbbbbaabbbbbcbbccc+++++++++++++::::
!!!!!aaaaaabbbbccccc;;;;;;;;bbbbbbbbbbbbcccccc:+++++++++++++::::
??!!!aaaaaaabbbbbccccc;;;;;;;;bbbbbbbcccccccc++++++++++++++++:::
???!!!!aaaaaabbbbbbcccc;;;;;ccbbbbccccccccc;+:+++++++++++++:+:::
?????!!!aaaaaaaabbbbbccccc;;cccbbbbcccccccc;;::::::++:::::::::::
0?????!!!!!!aaaaabbbbbcccccccccccccccccccc;;;:::::::::::::::::::
00?????!!!!!aaaaaaaabbbbbcccccbbbbbbbbccccc;;;;;::::::::::::;:;;
00000?????!!!!aaaaaaaabbbbbbbbbbbbbbbbcbccc;c;;;;;;;;;;;;;;;;;;;
100000??????!!!!!aaaaaaaabbbbbbbbbbbbbbbbbccc;;;;;;;;;;;;;;;;;;;
Published on

Optimal Transport and Perfect Matching

Authors

Why is this important?

The main reason I decided to look into matching algorithms is because of their value in finding the minimal cost in machine learning. This is extremely important because we can use these algorithm to compare distributions of data by posing it as a matching problem. In machine learning, this might be useful for calculating how well a model performs by comparing the Wasserstein distances between the performance on sample distribution and the full distribution.

What is a perfect matching:

A perfect matching is a graph where every vertex is matched to another vertex such that all vertices are covered with a single edge

How can we find perfect matchings?

Push-Relabel Algorithm:

We have dual weights for each vertex to maintain some invariants.

We have this function

CvwP=Cvwp(v)p(w)C^P_{vw} = C_{vw} - p(v) - p(w) where

  • CPC^P is the reduced cost
  • p(x)p(x) is the dual weight for vertex x
  • uu and vv are edges

Invariants:

  1. all reduced costs \geq 0
  2. Every eMe \in M is tight (Cvp,CeP=0)(C_{vp}, C^P_{e} = 0)

Theorem: If graph M is perfect and the invariants hold, the M is minimal cost

With this theorem we get the following linear program:

eCMCe=eCMCeP+vCp(v)\sum_{e \in C \cap M}C_e = \sum_{e \in C \cap M}C^P_e + \sum_{v \in C}p(v)

eCMCe=eCMCeP+vCp(v)\sum_{e \in C - M}C_e = \sum_{e \in C - M}C^P_e + \sum_{v \in C}p(v)

We can now iteratively solve for the minimal cost with a slack variable ϵ\epsilon

Application and WGAN

Earth movers Distance

infγ E(xy) \underset{\gamma}{inf} \space \mathbb{E} |(x - y)|

γ=π(P,Q)\gamma = \pi (P, Q)

Constraints on marginals

y(x,y)=Pr(u)\sum y(x, y) = P_r(u)

Problem with original GAN architecture is due to the use of KL-Divergence fails to compute distances when the two distribution or non-overlapping. WGAN addresses this by using Earth mover's Distance.

Transport Plan

EMD(Pr,Pθ)=infxyγ(x,y)=infEx,yγxyEMD(P_r, P_{\theta}) = \inf || x - y || \gamma(x,y) = \inf \mathbb{E}_{x, y \in \gamma} || x - y||

We can derive the dual formulation of EMD, by making this a maximization instead of a minimization

EMD(Pr,Pθ)supfL1(ExPr[f(x)]EyPθ[f(y)])EMD(P_r, P_\theta) \approx \sup_{\|f\|_L \leq 1} \left( \mathbb{E}_{x \sim P_r}[f(x)] - \mathbb{E}_{y \sim P_\theta}[f(y)] \right)

which satisfies f(x1)f(x2)x1x2|f(x_1) - f(x_2)| \leq |x_1 - x_2| for all (x1,x2)(x_1, x_2). This 1-Lipschitz condition ensures there is smoothness between two distributions on the discriminator corresponding to Epr[f(x)]\mathbb{E}_{p_r}[f(x)]

To ensure Lipschitz condition on a neural net we bound the weights by clipping them then the slope can't be bigger the magnitude of the clipping.

Wasserstein GAN uses this dual formulation of Earth Mover's Distance

minGmaxD[ExpdataD(x)EzpD(G(z))]min_G max_D [\mathbb{E}_{x \sim p_{data}}D(x) - \mathbb{E}_{z \sim p}D(G(z))]

The main difference between Wasserstein GAN and regular GAN objectives is that it uses linear activation instead of sigmoid in the discriminator and removes the logs