{'fraction_non_alphanumeric': 0.04529943695615083, 'fraction_numerical': 0.012668486606381164, 'mean_word_length': 4.080615451294832, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Connecting GANs, MFGs, and OT

Generative adversarial networks (GANs) have enjoyed tremendous success in image generation and processing, and have recently attracted growing interests in financial modelings. This paper analyzes GANs from the perspectives of mean-field games (MFGs) and optimal transport. More specifically, from the game theoretical perspective, GANs are interpreted as MFGs under Pareto Optimality criterion or mean-field controls; from the optimal transport perspective, GANs are to minimize the optimal transport cost indexed by the generator from the known latent distribution to the unknown true distribution of data. The MFGs perspective of GANs leads to a GAN-based computational method (MFGANs) to solve MFGs: one neural network for the backward Hamilton-Jacobi-Bellman equation and one neural network for the forward Fokker-Planck equation, with the two neural networks trained in an adversarial way. Numerical experiments demonstrate superior performance of this proposed algorithm, especially in the higher dimensional case, when compared with existing neural network approaches.


Introduction
GANs. Generative Adversarial Networks (GANs), introduced in [26], belong to the class of generative models. The key idea behind GANs is to interpret the process of generative modeling as a competing game between two neural networks: a generator network G and a discriminator network D. The generator network G attempts to fool the discriminator network by converting random noise into sample data, while the discriminator network D tries to identify whether the sample is faked or true.
After being introduced to the machine learning community, the popularity of GANs has grown exponentially with numerous applications. Some of the popular applications include high resolution image generation [19,45], image inpainting [61], image super-resolution [35], visual manipulation [64], text-to-image synthesis [46], video generation [55], semantic segmentation [39], and abstract reasoning diagram generation [25]. Recently GANs have been used for simulating financial timeseries data [56], [57], [62], and for asset pricing models [15]. Along with the empirical success of GANs, there is a growing emphasis on the theoretical analysis of GANs. [8] proposes a novel visualization method for the GANs training process through the gradient vector field of loss functions. In a deterministic GANs training framework, [41] demonstrates that regularization improved the convergence performance of GANs; [18] and [21] analyze a generic zero-sum minimax game including that of GANs, and connect the mixed Nash equilibrium Optimal transport. The theory of optimal transport, originated from Monge [42], studies the optimization problem of transporting one given initial distribution to another given terminal distribution so that the transport cost functional is minimized. Deeply rooted in linear programming, many theoretical works on the existence and uniqueness of an optimal transport plan focus on the duality gap between the primal optimization problem and its dual form. For instance, the Kantorovich-Rubinstein duality in [53] characterizes sufficient conditions for the existence of optimal transport plans (i.e., when there is no duality gap), and [27] studies the multi-marginal case.
Martingale optimal transport problem is motivated mostly by problems from finance, starting with the problem of super-hedging, see for instance [20], [37], and [44]. [5] establishes a complete duality theory for generic martingale optimal transport problems via a quasi-sure formulation of the dual problem; and [30] studies a continuous-time martingale optimal transport problem and establishes the duality theory via the S-topology and the dynamic programming approach.
To compute the optimal transport plan, [29] proposes a computational method for martingale optimal transport problems based on linear programming via proper relaxation of the martingale constraint and discretization of the marginal distributions; [22] proposes a deep learning algorithm to solve multi-step, multi-marginal optimal transport problem via its dual form with an appropriate penalty term.
Our work. So far, theories of GANs, MFGs, and optimal transport have been developed independently. We will show in this work that they are tightly connected. In particular, GANs can be understood and analyzed from the perspective of MFGs and optimal transport. More precisely, • We first show a conceptual connection between GANs and MFGs: MFGs have the structure of GANs, and GANs are MFGs under the Pareto Optimality criterion. This intrinsic connection is transparent for a class of MFGs for which there is a minimax game representation.
• We then establish rigorously an analytical connection between a broad class of GANs and optimal transport problems from the latent distribution to the true distribution. This representation is explicit for Wasserstein GANs as well as some its variations including relaxed Wasserstein GANs. At the core of this connection is the Kantorovich-Rubinstein type duality.
• We finally propose a GANs-based algorithm (MFGANs) to solve MFGs. This is derived from connecting the variational structure embedded in the PDE system for MFGs with the minimax game structure for GANs. This connection suggests a new neural network based approach to solve MFGs: one neural network for the backward HJB equation and the other for the forward FP equation, with the two neural networks trained in an adversarial way. Our numerical experiments demonstrate the performance of this proposed algorithm when compared with existing neural-network-based approaches, especially in higher dimensional case. This idea of developing neural network-based algorithm with incorporation of adversarial training appears promising for more general dynamic systems with variational structures.
Related ML techniques for computing MFGs. Most existing computational approaches for solving MFGs adopt traditional numerical schemes, such as finite differences [1] or semi-Lagrangian [10] schemes. Some exceptions are [12,11] and [32]. [32] designs reinforcement learning algorithms with convergence and complexity analysis for learning MFGs, where the cost function of the game as well as the parameters for the underlying dynamics are unknown. [2,12,11] propose deep neural networks approaches for solving MFGs, with a particular Deep-Galerkin-Method architecture, to approximate the density and the value function by neural networks separately. [38] proposes a GANs-based algorithm named APAC-Net via a primal-dual formulation associated with the coupled HJB-FP system by [17]; their numerical experiments demonstrate their capability of solving some special forms of high-dimensional MFGs. In contrast, our algorithm takes full advantage of the variational structure of MFGs and train the neural networks in an adversarial fashion. Our numerical experiment demonstrates clear advantage of this variational approach, especially in terms of computational efficiency for high dimensional MFGs.
Related works on connecting GANs and optimal transport. There are earlier studies exploring connections between GANs and optimal transport. For instance, [4] points out that the Wasserstein distance between true distribution P r and generated distribution P θ can be seen as the optimal transport cost from P r to P θ . [36] provides a geometric interpretation of Wasserstein GANs. This connection has also been exploited to improve the stability and performance of GANs training in [28], [49], and [16]. In addition, [48] defines a novel optimal transport-type divergence to replace the Jensen-Shannon divergence for GANs training. The work [40] studies the generalization property of GANs if the generator is jointly trained with latent distribution, where optimal transport metric is used for the discriminator. An unbalanced optimal transport problem is solved using GANs in [58]. Our work establishes this connection analytically and in a more general framework, to allow for a broader class of generative models without the symmetry condition on the loss function.
Organization. This paper is organized as follows. Section 2 focuses on the basic mathematics and preliminaries for GANs, MFGs and optimal transport problem. Section 3 demonstrates that GANs are MFGs in a collaborative setting. The connection between GANs and optimal transport is established in Section 4. Finally, Section 5 explains the analogy between the MFGs and GANs and provides a GAN-based algorithm with numerical experiments.
Notations. Throughout this paper, the following notations will be adopted, unless otherwise specified.
• X denotes a Polish space with metric l and Z denotes another Polish space with metric l z .
• P(X ) denotes the set of all probability distributions over the space X .
• P D (R d ) denotes the set of probability distributions on R d that admit corresponding density functions with respect to Lebesgue distribution.
• For p ≥ 1 and some arbitrary x 0 ∈ X , L p (X ) := µ ∈ P(X ) X l(x, x 0 ) p µ(dx) < ∞ . Note that this set is independent of the choice of x 0 .

GANs
GANs fall into the category of generative models. The procedure of generative modeling is to approximate an unknown probability distribution P r by constructing a class of suitable parametrized probability distributions P θ . That is, given a latent space Z and a sample space X , define a latent variable Z taking values in Z with a fixed probability distribution P z and a family of functions G θ : Z → X parametrized by θ. Then P θ is defined as the probability distribution of G θ (Z), denoted by Law(G θ (Z)).
The key idea of GANs as generative models is to introduce a competing neural network, namely a discriminator D = D ω : X → [0, 1], parametrized by ω. This discriminator assigns a score between 0 to 1 to each sample generated either from the true distribution P r or the approximate distribution P θ . A higher score from the discriminator D indicates that the sample is more likely to be from the true distribution. GANs are trained by optimizing G and D iteratively until D is very good at identifying which samples come from P r but the generator is so good that it can fool D to make it believe that the samples from P θ come from P r .
GANs as minimax games. As explained in the paper [26], GANs can be formally expressed as the following minimax game: Now, fixing G and optimizing for D in (1), the optimal discriminator would be where p r and p θ are density functions of P r and P θ = Law(G(Z)) respectively, assuming they exist. Plugging this back in (1), the GANs minimax game becomes That is, training of GANs with an optimal discriminator is equivalent to minimizing the Jensen-Shannon (JS) divergence between P r and P θ .
Viewing GANs training as an optimization problem between P r and P θ has led to variants of GANs with different choices of divergences, in order to improve the training performance: for instance, [43] uses f-divergence, [52] explores scaled Bregman divergence, [4] adopts Wasserstein-1 distance, [31] proposes relaxed Wasserstein divergence, and [48] and [49] utilize the Sinkhorn loss. This viewpoint is instrumental to establish the connection between GANs and optimal transport, studied in Section 4.
Equilibrium of GANs training. Under a fixed network architecture, the parametrized version of GANs training is to find From a game theory viewpoint, the objective in (2) is in fact the upper value of the two-player zero-sum game of GANs. Meanwhile, the lower value of the game is given by the following maximin Moreover, if there exists a pair of parameters (θ * , ω * ) achieving both (2) and (3), then (θ * , ω * ) is a Nash equilibrium of this two-player zero-sum game. As pointed out by Sion's theorem (see [54] and [50]), if L GAN is convex in θ and concave in ω, then there is no duality gap and v GAN It is worth noting that conditions for such an equality are usually not satisfied in many common GAN models, as stressed out in [63].

MFGs
GANs and coupled PDE Systems. MFGs are introduced to approximate Nash equilibria in N -player stochastic games by considering a game with infinitely many interchangeable agents.
The key idea of MFGs, thanks to the law of large numbers, is to study the interaction between a representative player and the aggregated information of all the opponents instead of focusing on each one of them individually. This aggregated information is often referred to as the mean-field information. Take for instance, a filtered probability space (Ω, F, {F t } t≥0 , P) which supports a standard d-dimensional Brownian motion W = {W t } t≥0 . A class of continuous-time MFGs is to find for the representative player an optimal control {α t } t≥0 with α t ∈ R d for all t ≥ 0 from an appropriate admissible control set, and to solve for the following minimization problem: For any s ∈ [0, T ] and x ∈ R d , find subject to the state dynamics Here, f : [0, ∞)×R d ×P D (R d )×R d → R represents the running cost. {µ t } t≥0 is a flow of probability measures characterizing the mean-field information, with initial distribution µ 0 = µ 0 ∈ P 2 (R d ) and µ 0 ⊥ σ(W t , t ≥ 0). In the state dynamics, σ > 0 is a constant diffusion coefficient; the drift term b : [0, ∞)×R d ×P D (R d )×R d → R d satisfies appropriate conditions ensuring the existence of a unique solution {X t } t≥0 for the state dynamics such that for any t ≥ 0, µ t = Law(X t ) ∈ P 2 (R d ) ( [47] and [23]). Moreover, µ t can be viewed as the limiting empirical distribution of identically distributed players' states, and by strong law of large numbers µ t = lim N →∞ copies of X t . The Nash equilibrium solution of this (MFG) is characterized by the following optimalityconsistency criterion. Definition 1. A control and mean-field pair ({α * t } t≥0 , {µ * t } t≥0 ), with initial distribution µ * 0 = µ 0 , is called the solution to (MFG) if the following conditions hold.
solves the following optimal control problem that: is the flow of probability distributions of the optimally controlled process, i.e., Correspondingly, solutions of this (MFG) can be characterized by the following coupled PDE system (assuming the mean-field interactions are of local type), Here, we denote by m(t, ·) as the density function of µ t for any t ≥ 0, and for any µ ∈ P D (R d ) with density function m, we will write b(t, x, µ, α) := b(t, x, m, α) and f (t, x, µ, α) := f (t, x, m, α) in the rest of this paper. The Hamiltonian H(s, x, p) in (HJB) is given by and α * in (FP) is the optimal control, with Note that from (4), the optimal control is determined by the value function u and mean field m.
Recently, a class of periodic MFGs on the flat torus T d with a finite time horizon [0, T ] have been shown to admit a minimax structure by [17]. This minimax structure is further explored to connect MFGs with GANs in Section 3 and 5.1.

Optimal transport problems
The optimal transport problem, dating back to Monge [42], is to find the best transport plan minimizing the cost to transport one mass with distribution µ to another mass with distribution ν.
Mathematically, consider a Polish space X with metric l : X × X → [0, ∞). Let µ and ν be any probability measures in P(X ) with a first moment. Let c : X × X → R {+∞} be a lower semi-continuous function such that c(x, y) ≥ a(x) + b(y), where a and b are upper semi-continuous functions from X to R ∪ {−∞} such that a ∈ L 1 (X , µ), b ∈ L 1 (X , ν). The optimal transport problem is defined as follows (see [53]). Definition 2. The optimal transport cost between µ and ν with cost function c is defined as where Π(µ, ν) is the set of all possible couplings between µ and ν.
The well-definedness of this optimal transport problem, i.e., the existence of an optimal cost W c , is guaranteed by Theorem 4.1 of [53]. The corresponding dual formulation of this optimal transport problem is defined as follows.
It is easy to see that D c (µ, ν) ≤ W c (µ, ν). The following Kantorovich-Rubinstein duality provides sufficient conditions to guarantee the equality. This duality is at the core of the relation between GANs and optimal transport to be established in the latter part of this paper. Lemma 1 (Theorem 5.10(i) in [53]).
Here ψ : X → R {+∞} is taken from the set of all c-convex functions, i.e., ψ is not constantly +∞ and there exists a function ζ : In a particular case where the transport cost c can be written as c(x, y) = l(x, y) p for some p ≥ 1, then the corresponding optimal cost gives rise to the Wasserstein distance between µ and ν of order p, or simply the Wasserstein-p distance, Note that for p = 1, the Wasserstein-1 distance is adopted in Wasserstein GANs (WGANs) in [4] to improve the stability of GANs.

GANs as MFGs
As reviewed in Section 2, GANs have been introduced as two-player minimax games between the generator and the discriminator. In this section, we will take the viewpoint of the training data and re-examine the game theoretical perspective of GANs. In particular, we will show that under this viewpoint, the theoretical framework of GANs can be interpreted as MFGs under Pareto Optimality conditions: Theorem 1. GANs in [26] are MFGs under the Pareto Optimality criterion.
To establish Theorem 1, we will start from a practical training scenario of GANs with a large amount of but finitely many data points (Z i , X j ), i = 1, . . . , N , j = 1, . . . , M and N, M finite. Here the N latent variables {Z i } N i=1 will be seen as N players on the generator side and the M true sample data {X j } M j=1 will be seen as the adversaries on the discriminator side. We will show that after the training process, the optimal generator corresponds to the Pareto optimal strategy of a class of N -player cooperative games and it can only recover the sample distribution of {X j } M j=1 . Then, we will show that as N, M → ∞, the N -player cooperative games will converge to the MFGs setting, corresponding to the theoretical GANs framework.

Cooperative game with N players against M adversaries
We will start from constructing the N -player cooperative games corresponding to a GANs model in training, with all players interchangeable. Let us first look at the state process of a representative generator player governed by the generator network G, parametrized by a feedforward neural network Here, T represents the depth of the neural network in which there are T + 1 layers with layer 0 being to the input. σ t denotes the activation function adopted to produce the output at layer t, t = 1, . . . , T . Finally, n t denotes the number of neurons at layer t, t = 1, . . . , T .
Recall that in GANs, the input of the generator Z is a random variable from the latent space Z ⊂ R n 0 and its distribution P z is known; the true samples follow an unknown distribution P r . Let X denote a random variable taking values in the sample space X ⊂ R n T and X ∼ P r .
State process of a representative player. Now, the state process of a player on the generator side is given by the feedforward process of generator network G. This computation process can be written as the following process, Here, H 0 denotes the input and H t denotes the output of layer t. w t takes values in Notice that under a given feedforward neural network structure In the analysis below, we will use G and (w, b) interchangeably whenever there is no risk of confusion. Denote the set of admissible controls by Given the mathematical setup for the state process above, we now move on to the definition of the cooperative game. Without loss of generality, we assume: 2. Both P z and P r are absolutely continuous with respect to Lebesgue measure on X , with density functions respectively p z and p r .
3. The activation functions {σ t } T t=1 are all continuous.
The players and the adversaries. Under a strategy G i = (w i , b i ) ∈ G, the state process for each individual player i is given by Let G N = (G 1 , . . . , G N ) denote a strategy profile for all N players and N i=1 G be the set of all possible strategy profiles.
Define the set of symmetric strategy profiles as and for simplicity we write The group of N players are coordinated by a central controller who is in charge of choosing a strategy applied by all the players. In particular, since the players are indistinguishable, the central controller picks a strategy profile in S(G). Since S G ∈ S(G), the state process for each individual player is given by for i = 1, . . . , N . Meanwhile, there are M adversaries against this group of N players, denoted by X j ∈ X , j = 1, . . . , M , and X j i.i.d.
The cost of the game. The cost for each individual player against the adversaries is measured by a discriminator function D from the set of measurable functions Under any given D ∈ D, the individual cost of choosing strategy G ∈ G is given by where we adopt the convention 0 log 0 = 0. The central controller from the player group will choose an optimal strategy profile S G ∈ S(G) to attain the minimal collective cost from all players even if the discriminator function D N,M is biased toward the group of adversaries in the following sense, That is, D N,M assigns higher scores to the adversaries compared with the players. The collective cost of choosing strategy profile S G is given by Note that this is a deterministic quantity (given the values of Pareto optimality of the cooperative game. The Pareto optimality to this cooperative game is specified as follows.
If such a Pareto optimal S G * exists for some G * ∈ G, then the corresponding game value is given by subject to (10) under G = G * for all i = 1, . . . , N . Given the data points {Z i } N i=1 and {X j } M j=1 and a fixed strategy G ∈ G, we first study the characterization through an optimality condition of D N,M . Define as the empirical measures of {X j } M j=1 and {H G i,T } N i=1 , respectively, where for any given y ∈ X , the Dirac delta function δ y is given by and as Dirac measure, for any Borel measurable set A ⊂ X . Then Hence, Proposition 1. Any optimal biased discriminator function D N, Having the function D N,M in (17), we can now derive the Pareto optimal solution S G * in S(G).
Theorem 2. Any Pareto optimal S G N, * by Definition 4 is given by some G N, * ∈ G N, * with where µ N G , µ M r are defined in (15), provided that G N, * = ∅.
Here, condition (18) means that the empirical generator's output must match the empirical distribution of the samples.
Theorem 2 shows that, in practical training of GANs over finite training samples, the best an optimal generator can achieve is to recover the sample distribution of the true sample data.
Proof. First, notice that Let P ({X 1 , . . . , X M }) denote the set of probability measures on {X 1 , . . . , X M }. Then the func- The conclusion follows.

Mean-field game when N goes to infinity
Now as N and M tend to infinity, instead of assigning to each and every one of the player a strategy, the central controller now considers .
We refer µ G as the mean-field information. Given the i.i.d. conditions on H G i,0 and the symmetric strategy profile, we can write µ G t = Law(H G t ) for t = 0, . . . , T , with H G given by (6). Note that H G i,T ∼ µ G T = P θ for all i = 1, 2, . . . . Now, instead of playing against M adversaries from the discriminator side as in the training scenario, the group of infinitely many generator players are now competing against the aggregated information of the adversaries, that is, the distribution of the adversaries P r . Under a given discriminator function D ∈ D, the cost of individual players for choosing strategy G ∈ G is given by for each i = 1, 2, . . . . The objective of the central controller is to choose an optimal symmetric strategy profile characterized by G ∈ G such that the collective cost of all players minimized even under a biased discriminator functionD toward the adversary group, such that where the equality is by the law of large numbers. Following a similar argument as for Proposition 1, we recover the following characterization ofD from [4].
Proposition 2. Any optimal biased discriminatorD satisfies: where Supp(p r ) and Supp(p θ ) denote the supports of p r and p θ , respectively. For x ∈ Supp(p r ) Supp(p θ ), D can take any value in [0,1].
Under this biased discriminator functionD, the collective cost of all players for choosing strategy G is then given by where the last equality is also due to the law of large numbers. The game value for the mean-field game under Pareto optimality condition is then given by subject to the state process (6) and µ G = {µ G t } T t=0 given by µ G t = Law(H G t ) for t = 0, . . . , T . With a similar proof as for Theorem 2, we have the following result for solving the mean-field game (23). Theorem 3. The mean-field game (23) can be solved by any G mf, * ∈ G mf, * where provided that G mf, * = ∅.
By the continuous mapping theorem, we have the following connection between the N -player game (14) and the mean-field games (23). Notice that under a neural network structure specified by (5), the weights w * = {w * t } T t=0 and biases b * = {b * t } T t=0 given by G mf, * = (w * , b * ) ∈ G mf, * coincides with the training objective of the vanilla GANs structure proposed in [26]. Therefore, Theorem 1 follows directly from Theorem 4.

Remark 1.
1. The N -player cooperative game corresponds to the training of GANs in practice, where the training is over a finite dataset , whereas the mean-field game corresponds to the theoretical frame of GANs where both P z and P r can be perfectly simulated on an infinite supply of data. The non-emptiness of G N, * and G mf, * will rely on the design of the generator network architecture.
2. Mean-field games under Pareto Optimality condition are often referred to as the mean-field control problems, see for instance [7,13].

GANs and optimal transport
In this section, we will show that, from the perspective of a dynamical version of optimal transport, GANs are optimal transport problems from the known prior distribution P z of the latent variable Z ∈ Z to the unknown true distribution P r over the sample space X . Intuitively, this connection between the optimal transport problem and GANs is as follows. In the optimal transport problem [6], the mass transport from a source distribution to a target distribution is seen as the evolution of a density field from the source density function to the target density function according to a given differential equation characterized by a carefully chosen velocity field. In the context of GANs, the evolution of the density flow is cast as the forward pass within the generator network G, as specified in (6). Let {µ G t = Law(H G t )} T t=0 denote the flow of probability measures generated by this dynamic, with initial distribution µ G 0 = P z . Then the goal of GANs is to find an optimal generator network G * , which is also an optimal transport map, such that both the initial condition µ G * 0 = P z and the terminal condition µ G * T = P r hold. Note that such G * 's may not be unique, as pointed out in [6]. Nevertheless, with a proper choice of transport cost, i.e., the loss function in GANs, one particular transport map G * can be determined. In fact, this optimal transport viewpoint of GANs can be explicitly constructed in the case of WGANs.
To establish this connection rigorously, recall that the latent variable Z ∈ Z with Z ∼ P z and the sample space X is a metric space with distance function l : X × X → R + . Fix an arbitrary x 0 ∈ X and denote G(l, x 0 ) = G : Z → X : G continuous and Law(G(Z)) ∈ L 1 (X ; x 0 ) .
Assume P r ∈ L 1 (X ; x 0 ) and denote by Π(P z , P r ) the set of all possible couplings of P z and P r . For any fixed G ∈ G(l, x 0 ), define the following transport cost function c G : Z × X → R + such that Accordingly, we have the following optimal transport problem from P z to P r : Its corresponding dual problem is then given by A function φ : X → R∪{+∞} is c G -concave if it is not constantly +∞ and there exists a c G -convex function ψ such that φ = ψ c ; its c G -transform is given by

Now, denote
Note that Lip 1 (X , l) is equivalent to the set of 1-Lipschitz functions from X to R with respect to metric l. Moreover, we have Proof. We first prove that φ ∈ Lip 1 (X , l) is included in the set of c G -concave functions. Let φ ∈ Lip 1 (X , l). Then for any (z, x) ∈ Z × X , φ(x) < +∞ and Note that there is equality if x = G(z). Therefore, φ • G : Z → R is c G -convex. Since G(Z) = X , for any x ∈ X , there exists z(x) ∈ Z such that G(z(x)) = x. For any (z, x) ∈ Z × X , We now prove the converse inclusion. For the sake of contradiction, suppose there exists a c Gconcave function φ 0 that is not 1-Lipschitz. Due to c G -concavity, there exists a c G -convex function Since ψ 0 is not constantly +∞, given the form of ψ c 0 and c G , φ 0 is finite everywhere. Hence, φ 0 not being 1-Lipschitz implies that there exists x, y ∈ X such that φ 0 (x) − φ 0 (y) > l(y, x). We have For any > 0, there exists z( ) ∈ Z such that φ 0 (y) > ψ 0 (z( )) + c G (z( ), y) − .
where the equality is by definition of c G . Since (29) holds for any > 0, we arrive at a contradiction that φ 0 (x) − φ 0 (y) ≤ l(x, y). Therefore, a function φ : X → R ∪ {+∞} is c G -concave if and only if it is 1-Lipschitz with respect to metric l.
Note that an informal form of the lemma can be found in [53] regarding the equivalence between the set of 1-Lipschitz functions and the set of c-concave functions when computing Wasserstein-1 distance between two distributions in P(X ). Here we establish rigorously this equivalence for optimal transport problem from P z ∈ P(Z) to P r ∈ P(X ).
This lemma, the foundational piece of a duality theory for the optimal transport problem (OT-G), enables us to connect GANs and optimal transport from the latent distribution P z to the true distribution P r . The duality is explicit in the case of WGANs, and can be utilized to cover a broad class of GANs including the relaxed Wasserstein GANs [31], in which the metric function is replaced with the Bregman divergence.
Theorem 5. Suppose that P r ∈ L 1 (X ; x 0 ) for some x 0 ∈ X . WGAN is equivalent to the following optimization problem, min where W c G (P z , P r ) is given by (OT-G).
Proof. For any G ∈ {G ∈ G(l, x 0 ) : for any (z, x) ∈ Z × X . Since a(·) = l(G(·), x 0 ) ∈ L 1 (Z, P z ) and b(·) = l(·, x 0 ) ∈ L 1 (X , P r ), by [53,Theorem 5.10] and Lemma 2, Notice the form of c G in (26) that c G (z, x) = l(G(z), x) for any (z, x) ∈ Z × X , we have If there exists π * ∈ Π(P z , P r ) such that 1 = π * (Z × X ) = π * ({(z, x) : Furthermore, for any B x ⊂ X , To extend this explicit connection between WGANs and the optimal transport to other variations such as relaxed Wasserstein GANs, consider a quasi-metricl : X × X → R instead of a metric function l such that 1.l(x, y) ≥ 0 and the equality holds if and only if x = y; 2.l(x, y) ≤l(x, z) +l(z, y) for any x, y, z ∈ X .
That is,l relaxes the symmetric property of l. Then, for a fixed x 0 ∈ X , define G(l, x 0 ) = G : Z → X : G continuous and For any G ∈ G(l, x 0 ), letc G : Z × X → R such thatc G (z, x) =l(G(Z), x) for any (x, z) ∈ Z × X . Theorem 6. Suppose that P r satisfies Xl (x 0 , x)P r (dx) < ∞. The proof of Theorem 6 follows the same arguments in the proofs of Lemma 2 and Theorem 5.

Computing MFGs via GANs
In Section 3, GANs are conceptually interpreted as MFGs among players whose state process is captured by the forward pass within the generator network. In this section, we will show the inverse interpretation of MFGs as GANs, from which a new computational approach for solving MFGs is proposed and tested through several examples.

MFGs as GANs
MFGs recast as GANs. First, we claim that MFGs can be recast as GANs.
To see this, recall from Section 2 that in classical GANs, the generator G mimics the sample data to generate new ones in order to minimize the difference between the true distribution P r and P θ . The discriminator D measures the performance of the generator by some divergence between P θ and P r . Meanwhile, MFGs can be recast in this context such that • The latent space Z = R d and sample x of latent variable Z are drawn from the probability distribution P z = µ 0 .
• The value function u maps the element x into R so that it gives the optimal cost and its gradient dictates the optimal strategy in the equilibrium state of the MFGs. We can then define a loss function where β V al > 0 denotes the weight on the penalty of the terminal condition, with , ∆ x u(s, x))| 2 µ(dx, ds), • The equilibrium state of the MFGs, parallel to the true distribution P r in GANs, is characterized through a consistency condition between the value function and the controlled dynamics. The mean-field term m attempts to approximate the equilibrium state process (2.2) under the optimal control given by the value function. Its loss, in place of the divergence function between P θ and P r , is defined as where β M F > 0 denotes the weight on the penalty of the initial condition, with and Here α * u,m denotes the optimal control solved under current u and m. Discriminator D neural network measuring divergence between P θ and P r neural network for value function u (solving HJB) Now MFGs can be recast as GANs with m as a generator and u as a discriminator. In this case, m tries to learn how to mimic the equilibrium mean-field distribution and u learns how to penalize samples that are deviating from this equilibrium, as summarized in Table 1.
For some classes of MFGs, this connection with GANs is even more explicit, as we explain next.
Example. Let us review the following class of periodic MFGs on the flat torus T d from [17] in which the individual agent's cost is: where X α = (X α t ) t is a d-dimensional process whose initial distribution has density m 0 such that Here α : [0, T ] × R d → R d is a control policy, L and f constitute the running cost, and m(t, ·), for t ∈ [0, T ], denotes a probability density which corresponds to the law of X α t at equilibrium. Consider the convex conjugate of the running cost L, defined as: This class of MFGs can be characterized by the following coupled PDE system corresponding to (HJB)-(FP), where the first equation is an HJB equation governing the value function and the second is a FP equation governing the evolution of the optimally controlled state process. The system of equations (32) can be shown to be the system of optimality conditions for the following minimax game: where The connection between GANs and MFGs is transparent from (33).

Computing MFGs via GANs
The interpretation of MFGs as GANs points to a new computational approach for MFGs using two competing neural networks, assuming that the equilibrium of MFGs can be computed via the coupled HJB-FB system. That is, one can compute MFGs using two neural networks trained in an adversarial way as in GANs, with: • u θ being the neural network approximation of the unknown value function u for the HJB equation, • m ω being the neural network approximation for the unknown mean field information function m.
This new computational algorithm for MFGs is summarized in Algorithm 1. Note that here the two neural networks are trained in alternating periods of length respectively N ω and N θ . Furthermore, each neural network is trained to minimize a loss function hence the iterations are a gradient descent in each case.
In the algorithm, for B g samples (s, to train the generator, the empirical loss is defined as:L with the FP PDE residual's empirical loss and the initial condition's empirical loss being defined as: where m 0 is a known density function for the initial distribution of the states and β M F > 0 is the weight for the penalty on the initial condition of m. Moreover, for B d samples (s, to train the discriminator, the empirical loss is defined as: with the HJB PDE residual's empirical loss and the terminal condition's empirical loss being defined as:L where β V al > 0 is the weight for the penalty on the terminal condition of u.
Note that Algorithm 1 can be adapted for broader classes of dynamical systems with variational structures. Such GANs structures have been exploited in [59] and [60] to synthesize complex systems governed by physical laws.
Note also there are various ways to recast MFGs as GANs. For instance, one can swap the roles and view u as a generator (which solves the HJB equation via one neural network) and m as a discriminator (which computes an appropriate differential residual of the FP equation via another neural network).

Algorithm 1 MFGANs
Input: Initial parameters θ 0 , ω 0 . Learning rates α d , α g > 0. Number of training samples B d and B g for FP and HJB residuals. Prior distribution p prior . Numbers N θ and N ω of training steps of the inner-loops and number K of outer-loops Output: Parameters θ, ω such that u θ , m ω approximately solve the MFG PDE system Initialize θ ← θ 0 and ω ← ω 0

Numerical experiments
We now assess the quality of the proposed Algorithm 1. We start with a class of ergodic MFGs, for both one-dimensional and high-dimensional cases. This class of MFGs is chosen because of their explicit solution structures, which facilitate numerical comparison. We then apply the algorithm to a different class of high-dimensional MFGs for which there are no known explicit solutions.

A class of ergodic MFGs with explicit solutions
Consider (MFG) with the following long-run average cost, where the cost of control and running cost are given by In this ergodic setting, the PDE system (HJB)-(FP) becomes where the convex conjugate H 0 of L defined by (31) is given by H 0 (x, p) = sup α {α·p− 1 2 |α| 2 }−f (x). Here, the periodic value function u, the periodic density function m, and the unknown ergodic constantH can be explicitly derived as discussed in [3]. Indeed, assuming the existence of a smooth solution (m, u,H), m in the second equation in (37) can be written as m(x) = e 2u(x) T d e 2u(x ) dx . Hence the solution to (37) is given by u(x) = d i=1 sin(2πx i ) and the ergodic constant isH = ln The optimal control policy is also explicitly given by  Implementation. Both the value function u and the density function m are computed via neural networks with parameters θ and ω respectively. Moreover, • The neural network m ω is assumed to be a maximum entropy probability distribution, i.e., of the form m ω ∝ exp f ω for some neural network f ω . This is due to the lack of information about the density function m. (See also [24]). The density function m ω is normalized and therefore β M F = 0.
• The network architecture for implementing both u θ and f ω adopts the Deep Galerkin Method (DGM) architecture proposed in [51]. The DGM architecture is known to be useful for solving PDEs numerically. (See for instance [51,2,12]). The DGM network for both u θ and f ω contains 1 hidden layer of DGM type with 4 nodes. The activation function for u θ is hyperbolic tangent function and that of f ω is sigmoid function.  Since the MFG is of ergodic type with a specified periodicity, the architecture and Algorithm 1 are adapted accordingly. More precisely, • To accommodate the periodicity given by the domain flat torus T d , for any data point as input. The x i s and y i s here are the latent variables in the vanilla GANs.
• An additional trainable variableH is introduced in the graphical model.
• The loss functionsL HJB andL F P are modified according to the first and second equations of (37). The generator penalty becomeŝ For the weight for the generator penalty, we used β V al = 1.
• As GANs can be trained in an alternative fashion between the generator and discriminator, we make the following changes in this experiment to suit our training objective: Within each iteration, we first update the generator by N θ = 5 stochastic gradient descent (SGD) steps with initial learning rate 1 × 10 −3 and then update of the discriminator by N ω = 2 SGD steps with initial learning rate 1 × 10 −4 . The minibatch sizes are set to be B g = B d = 32. The number of total iterations, i.e., the number of outer loops is K = 10 5 . Adam optimizer is used for the updates.  Performance evaluations. To assess the performance of our algorithm, the following procedure is adopted.
• Given the explicit solution to the MFG (37), we compare the learnt value function, the learnt density function and the learnt optimal control against their respective analytical form.
• We adopt the evolution of relative l 2 errors between the learnt and true value and density functions. The relative l 2 error of a function f against another function g, with f, g : T d → R and g not constant 0, is given by Moreover, to facilitate comparisons for broader classes of MFGs whose analytical solutions may not be available, additional loss functions are adopted. Here we take differential residuals of both the HJB and the FP equations as measurement of the performance.    The results are presented in Figures 1 and 2. Figures 1a and 1b show the learnt functions of u and m against the true ones, respectively, and Figure 1c shows the optimal control. Both figures demonstrate the accuracy of the learnt functions versus the true ones. This strong performance is supported by the plots of loss in Figures 2a and 2b, depicting the evolution of relative l 2 error as the number of outer iterations grows to K. Within 10 5 iterations, the relative l 2 error of u oscillates around 3 × 10 −2 , and the relative l 2 errors of m decreases below 10 −3 .
The evolution of the HJB and FP differential residual loss (see L HJB and L F P ) is shown in Figures 2e and 2f, respectively. In these figures, the solid line is the average loss over 3 experiments, with standard deviation captured by the shaded region around the line. Both differential residuals first rapidly descend to the magnitude of 10 −2 ; then the descent slows down and is accompanied by oscillation.
One may notice the difference between the training results of u and m: one reason being that u and m are implemented using different neural networks; the other being that different loss functions are adopted for training u and m.   Sensitivity analysis. To understand possible contributing factors for the oscillation in the loss, especially for u, a sensitivity analysis on the learning rate of the generator α g is conducted. In our test, the initial learning rate for the Adam Optimizer α 0 g takes the values of 5 × 10 −4 , 1 × 10 −3 , 1 × 10 −2 and 5 × 10 −2 , respectively.
In Figures 2a and 2b, the relative l 2 error on u oscillates more than that of m. Similar phenomenon is observed in Figure 3. In particular, in Figure 3a, a drastic decrease in oscillation can be seen as the generator learning rate α g decreases.
Turning to the differential residual losses, one can observe from Figures 4 and 5 that decreasing α 0 g from 5 × 10 −2 to 5 × 10 −4 reduces the residual losses for both HJB and FP with less oscillation. Another parameter of interest is the number of samples in each minibatch, i.e., B g and B d in Algorithm 1. The cases of B g = B d = 32, 64, 128, and 256 are tested respectively. Figure 6a shows that the relative l 2 error of u oscillates less as B g and B d increases from 32 to 256. Moreover, comparing the cases of B g = B d = 32 and B g = B d = 256, the residual losses for both HJB and FP decrease with less oscillation as minibatch size increases, as shown in Figures 7 and 8.

Experiments in dimension 4.
We also conduct experiments in dimension 4. In this case, a different initial learning rate 5 × 10 −4 is adopted for the generator, and the number of outer loops is increased to K = 2 × 10 5 . Figure 9 shows the relative l 2 errors between learnt and true value and density functions. Within 2 × 10 5 iterations, the relative l 2 error of u decreases below 2 × 10 −2 and that of m decreases to 4 × 10 −3 . In fact, the training result stabilizes after around 8 × 10 4 iterations.
Finally, it is worth noting that similar experiment for dimension 4 has been conducted in [12] with a simple fully connected architecture; see their Test Case 4. In comparison, their algorithm needs a larger number of iterations (10 6 of iterations vs our 8 × 10 4 ), in order to achieve the same level of accuracy. The computational cost of one SGD iteration with fully connected architecture is lower than with the DGM architecture that we use but making a rigorous comparison in terms of computational time is quite challenging due to the details of the implementation. However, needing a smaller number iterations (and hence a smaller number of training samples) is an objective advantage of the results we obtained here.

Ergodic MFGs without explicit solutions
We next test Algorithm 1 for a class of MFGs for which no explicit solutions are available. Take ergodic MFGs (36) on R d , where L(x, α) = 1 2 |α| 2 +f (x), f (x, m) = m 2 + 1, The solution to this MFG can be characterized by the coupled PDE system (37).
In the experiment, we will show that Algorithm 1 not only can be adopted to solve this MFG problem in a multi-dimensional case, for instance d = 8, but also can capture the periodicity with appropriate choices of error functions, even without the a priori transformation of input given by (38).
Experiment setup. Similar as the previous experiments, the DGM model is adopted to parametrize both the value function u and the density function m with parameters θ and ω, respectively and a maximum entropy probability distribution is adopted when modelling the density function m.
There are a few differences compared with the previous experiment setup as follows.
• In the DGM network to parametrize the density function, the activation function of the output layer of m ω is set specifically to be exponential. Instead of normalizing m ω beforehand, we utilize the following normalization condition for the density function with β M F = 10 3 .
• Both DGM networks of u θ and m ω contain 3 hidden layers with 40 nodes, with hyperbolic tangent as activation functions.
• Within each iteration of training, the SGD steps for updating θ and ω are now set to be N θ = N ω = 10. Initial learning rates for both neural networks are chosen to be 3 × 10 −3 . The minibatch sizes are B g = B d = 1000. The total number of iterations is K = 10 5 .
• To capture the periodicity condition for both u θ and m ω , additional penalty terms are added to bothL M F andL V al such that  The results are summarized in Figure 10. After 10 5 iterations of training, the generator losŝ L V al drops below 10 −3 and the discriminator lossL M F reaches 10 −2 . The detailed losses are shown in Figure 11. Note that not only the coupled PDE system (37) is numerically solved accurately, the periodicity condition for both the value function and the density function has been well satisfied.