Differentiable Game Mechanics
Alistair Letcher, David Balduzzi, Sebastien Racaniere, James Martens, Jakob Foerster, Karl Tuyls, Thore Graepel
Introduction
A significant fraction of recent progress in machine learning has been based on applying gradient descent to optimize the parameters of neural networks with respect to an objective function. The objective functions are carefully designed to encode particular tasks such as supervised learning. A basic result is that gradient descent converges to a local minimum of the objective function under a broad range of conditions (Lee et al., 2017). However, there is a growing set of algorithms that do not optimize a single objective function, including: generative adversarial networks (Goodfellow et al., 2014; Zhu et al., 2017), proximal gradient TD learning (Liu et al., 2016), multi-level optimization (Pfau and Vinyals, 2016), synthetic gradients (Jaderberg et al., 2017), hierarchical reinforcement learning (Wayne and Abbott, 2014; Vezhnevets et al., 2017), intrinsic curiosity (Pathak et al., 2017; Burda et al., 2019), and imaginative agents (Racanière et al., 2017). In effect, the models are trained via games played by cooperating and competing modules.
The time-average of iterates of gradient descent, and other more general no-regret algorithms, are guaranteed to converge to coarse correlated equilibria in games (Stoltz and Lugosi, 2007). However, the dynamics do not converge to Nash equilibria – and do not even stabilize in general (Mertikopoulos et al., 2018; Papadimitriou and Piliouras, 2018). Concretely, cyclic behaviors emerge even in simple cases, see example 1.
This paper presents an analysis of the second-order structure of game dynamics that allows to identify two classes of games, potential and Hamiltonian, that are easy to solve separately. We then derive symplectic gradient adjustmentSource code is available at https://github.com/deepmind/symplectic-gradient-adjustment. (SGA), a method for finding stable fixed points in games. SGA’s performance is evaluated in basic experiments.
Tractable algorithms that converge to Nash equilibria have been found for restricted classes of games: potential games, two-player zero-sum games, and a few others (Hart and Mas-Colell, 2013). Finding Nash equilibria can be reformulated as a nonlinear complementarity problem, but these are ‘hopelessly impractical to solve’ in general (Shoham and Leyton-Brown, 2008) because the problem is PPAD hard (Daskalakis et al., 2009).
Players are primarily neural nets in our setting. For computational reasons we restrict to gradient-based methods, even though game-theorists have considered a much broader range of techniques. Losses are not necessarily convex in any of their parameters, so Nash equilibria are not guaranteed to exist. Even leaving existence aside, finding Nash equilibria in nonconvex games is analogous to, but much harder than, finding global minima in neural nets – which is not realistic with gradient-based methods.
There are at least three problems with gradient-based methods in games. Firstly, the potential existence of cycles (recurrent dynamics) implies there are no convergence guarantees, see example 1 below and Mertikopoulos et al. (2018). Secondly, even when gradient descent converges, the rate of convergence may be too slow in practice because ‘rotational forces’ necessitate extremely small learning rates, see figure 4. Finally, since there is no single objective, there is no way to measure progress. Concretely, the losses obtained by the generator and the discriminator in GANs are not useful guides to the quality of the images generated. Application-specific proxies have been proposed, for example the inception score for GANs (Salimans et al., 2016), but these are of little help during training. The inception score is domain specific and is no substitute for looking at samples. This paper tackles the first two problems.
2 Outline and summary of main contributions
We start with the basic case of a zero-sum bimatrix game: example 1. It turns out that the dynamics under simultaneous gradient descent can be reformulated in terms of Hamilton’s equations. The cyclic behavior arises because the dynamics live on the level sets of the Hamiltonian. More directly useful, gradient descent on the Hamiltonian converges to a Nash equilibrium.
Lemma 1 shows that the Jacobian of any game decomposes into symmetric and antisymmetric components. There are thus two ‘pure’ cases corresponding to when the Jacobian is symmetric and anti-symmetric. The first case, known as potential games (Monderer and Shapley, 1996), have been intensively studied in the game-theory literature because they are exactly the games where gradient descent does converge.
Algorithms.
The general case, neither potential nor Hamiltonian, is more difficult and is therefore the focus of the remainder of the paper. Section 3 proposes symplectic gradient adjustment (SGA), a gradient-based method for finding stable fixed points in general games. Appendix A contains TensorFlow code to compute the adjustment. The algorithm computes two Jacobian-vector products, at a cost of two iterations of backprop. SGA satisfies a few natural desiderata explained in section 3.1: () it is compatible with the original dynamics; and it is guaranteed to find stable equilibria in () potential and () Hamiltonian games.
For general games, correctly picking the sign of the adjustment (whether to add or subtract) is critical since it determines the behavior near stable and unstable equilibria. Section 2.4 defines stable equilibria and contrasts them with local Nash equilibria. Theorem 10 proves that SGA converges locally to stable fixed points for sufficiently small parameters (which we quantify via the notion of an additive condition number). While strong, this may be impractical or slow down convergence significantly. Accordingly, lemma 11 shows how to set the sign so as to be attracted towards stable equilibria and repelled from unstable ones. Correctly aligning SGA allows higher learning rates and faster, more robust convergence, see theorem 15. Finally, theorem 17 tackles the remaining class of saddle fixed points by proving that SGA locally avoids strict saddles for appropriate parameters.
Experiments.
We investigate the empirical performance of SGA in four basic experiments. The first experiment shows how increasing alignment allows higher learning rates and faster convergence, figure 4. The second set of experiments compares SGA with optimistic mirror descent on two-player and four-player games. We find that SGA converges over a much wider range of learning rates.
The last two sets of experiments investigate mode collapse, mode hopping and the related, less well-known problem of boundary distortion identified in Santurkar et al. (2018). Mode collapse and mode hopping are investigated in a setup involving a two-dimensional mixture of 16 Gaussians that is somewhat more challenging than the original problem introduced in Metz et al. (2017). Whereas simultaneous gradient descent completely fails, our symplectic adjustment leads to rapid convergence – slightly improved by correctly choosing the sign of the adjustment.
Finally, boundary distortion is studied using a 75-dimensional spherical Gaussian. Mode collapse is not an issue since there the data distribution is unimodal. However, as shown in figure 10, a vanilla GAN with RMSProp learns only one of the eigenvalues in the spectrum of the covariance matrix, whereas SGA approximately learns all of them.
The appendix provides some background information on differential and symplectic geometry, which motivated the developments in the paper. The appendix also explores what happens when the analogy with classical mechanics is pushed further than perhaps seems reasonable. We experiment with assigning units (in the sense of masses and velocities) to quantities in games, and find that type-consistency yields unexpected benefits.
3 Related work
Nash (1950) was only concerned with existence of equilibria. Convergence in two-player games was studied in Singh et al. (2000). WoLF (Win or Learn Fast) converges to Nash equilibria in two-player two-action games (Bowling and Veloso, 2002). Extensions include weighted policy learning (Abdallah and Lesser, 2008) and GIGA-WoLF (Bowling, 2004). Infinitesimal Gradient Ascent (IGA) is a gradient-based approach that is shown to converge to pure Nash equilibria in two-player two-action games. Cyclic behaviour may occur in case of mixed equilibria. Zinkevich (2003) generalised the algorithm to -action games called GIGA. Optimistic mirror descent approximately converges in two-player bilinear zero-sum games (Daskalakis et al., 2018), a special case of Hamiltonian games. In more general settings it converges to coarse correlated equilibria.
Convergence has also been studied in various -player settings, see Rosen (1965); Scutari et al. (2010); Facchinei and Kanzow (2010); Mertikopoulos and Zhou (2016). However, the recent success of GANs, where the players are neural networks, has focused attention on a much larger class of nonconvex games where comparatively little is known, especially in the -player case. Heusel et al. (2017) propose a two-time scale methods to find Nash equilibria. However, it likely scales badly with the number of players. Nagarajan and Kolter (2017) prove convergence for some algorithms, but under very strong assumptions (Mescheder et al., 2018). Consensus optimization (Mescheder et al., 2017) is closely related to our proposad algorithm, and is extensively discussed in section 3. A variety of game-theoretically or minimax motivated modifications to vanilla gradient descent have been investigated in the context of GANs, see Mertikopoulos et al. (2019); Gidel et al. (2018).
Learning with opponent-learning awareness (LOLA) infinitesimally modifies the objectives of players to take into account their opponents’ goals (Foerster et al., 2018). However, Letcher et al. (2019) recently showed that LOLA modifies fixed points and thus fails to find stable equilibria in general games.
Symplectic gradient adjustment was independently discovered by Gemp and Mahadevan (2018), who refer to it as “crossing-the-curl”. Their analysis draws on powerful techniques from variational inequalities and monotone optimization that are complementary to those developed here – see for example Gemp and Mahadevan (2016, 2017); Gidel et al. (2019). Using techniques from monotone optimization, Gemp and Mahadevan (2018) obtained more detailed and stronger results than ours, in the more particular case of Wasserstein LQ-GANs, where the generator is linear and the discriminator is quadratic (Feizi et al., 2017; Nagarajan and Kolter, 2017).
Network zero-sum games are shown to be Hamiltonian systems in Bailey and Piliouras (2019). The implications of the existence of invariant functions for games is just beginning to be understood and explored.
Dot products are written as or . The angle between two vectors is . Positive definiteness is denoted .
The Infinitesimal Structure of Games
In contrast to the classical formulation of games, we do not constrain the parameter sets to the probability simplex or require losses to be convex in the corresponding players’ parameters. Our motivation is that we are primarily interested in use cases where players are interacting neural nets such as GANs (Goodfellow et al., 2014), a situation in which results from classical game theory do not straightforwardly apply.
It is sometimes convenient to write where concatenates the parameters of all the players other than the , which is placed out of order by abuse of notation.
The simultaneous gradient is the gradient of the losses with respect to the parameters of the respective players:
By the dynamics of the game, we mean following the negative of the vector field, , with infinitesimal steps. There is no reason to expect to be the gradient of a single function in general, and therefore no reason to expect the dynamics to converge to a fixed point.
Hamiltonian mechanics is a formalism for describing the dynamics in classical physical systems, see Arnold (1989); Guillemin and Sternberg (1990). The system is described via canonical coordinates . For example, often refers to position and to momentum of a particle or particles.
The Hamiltonian of the system is a function that specifies the total energy as a function of the generalized coordinates. For example, in a closed system the Hamiltonian is given by the sum of the potential and kinetic energies of the particles. The time evolution of the system is given by Hamilton’s equations:
An importance consequence of the Hamiltonian formalism is that the dynamics of the physical system – that is, the trajectories followed by the particles in phase space – live on the level sets of the Hamiltonian. In other words, the total energy is conserved.
2 Hamiltonian Mechanics in Games
The next example illustrates the essential problem with gradients in games and the key insight motivating our approach.
has a Nash equilibrium at . The simultaneous gradient rotates around the Nash, see figure 1.
Remarkably, the dynamics can be reformulated via Hamilton’s equations in the coordinates given by the SVD of :
The vector field cycles around the equilibrium because conserves the Hamiltonian’s level sets (i.e. ). However, gradient descent on the Hamiltonian converges to the Nash equilibrium. The remainder of the paper explores the implications and limitations of this insight.
Papadimitriou and Piliouras (2016) recently analyzed the dynamics of Matching Pennies (essentially, the above example) and showed that the cyclic behavior covers the entire parameter space. The Hamiltonian reformulation directly explains the cyclic behavior via a conservation law.
3 The Generalized Helmholtz Decomposition
The Jacobian of a game with dynamics is the -matrix of second-derivatives {\mathbf{J}}({\mathbf{w}}):=\nabla_{\mathbf{w}}\cdot\boldsymbol{\xi}({\mathbf{w}})^{\intercal}=\Big{(}\frac{\partial\xi_{\alpha}({\mathbf{w}})}{\partial w_{\beta}}\Big{)}_{\alpha,\beta=1}^{d}, where is the entry of the -dimensional vector . Concretely, the Jacobian can be written as
The Jacobian of any vector field decomposes uniquely into two components where is symmetric and is antisymmetric.
Proof Any matrix decomposes uniquely as where and are symmetric and antisymmetric. The decomposition is preserved by orthogonal change-of-coordinates: given orthogonal matrix , we have since the terms remain symmetric and antisymmetric. Applying the decomposition to the Jacobian yields the result.
The connection to the classical Helmholtz decomposition in calculus is sketched in appendix B. Two natural classes of games arise from the decomposition:
A game is a potential game if the Jacobian is symmetric, i.e. if . It is a Hamiltonian game if the Jacobian is antisymmetric, i.e. if .
Potential games are well-studied and easy to solve. Hamiltonian games are a new class of games that are also easy to solve. The general case is more difficult, see section 3.
4 Stable Fixed Points (SFPs) vs Local Nash Equilibria (LNEs)
There are (at least) two possible solution concepts in general differentiable games: stable fixed points and local Nash equilibria.
We introduce local Nash equilibria because finding global Nash equilibria is unrealistic in games involving neural nets. Gradient-based methods can reliably find local – but not global – optima of nonconvex objective functions (Lee et al., 2016, 2017). Similarly, gradient-based methods cannot be expected to find global Nash equilibria in nonconvex games.
A fixed point with is stable if and is invertible, unstable if and a strict saddle if has an eigenvalue with negative real part. Strict saddles are a subset of unstable fixed points.
The definition is adapted from Letcher et al. (2019), where conditions on the Jacobian hold at the fixed point; in contrast, Balduzzi et al. (2018a) imposed conditions on the Jacobian in a neighborhood of the fixed point. We motivate this concept as follows.
Another viewpoint is that invertibility and positive semidefiniteness of the Hessian together imply positive definiteness, and the notion of stable fixed point specializes, in a one-player game, to local minima that are detected by the second partial derivative test. These minima are precisely those which gradient-like methods provably converge to. Stable fixed points are defined by analogy, though note that invertibility and semidefiniteness do not imply positive definiteness in -player games since may not be symmetric.
The conditions and are equivalent to the conditions on the symmetric component and respectively, since
for all , by antisymmetry of . This equivalence will be used throughout.
Stable fixed points and local Nash equilibria are both appealing solution concepts, one from the viewpoint of optimisation by analogy with single objectives, and the other from game theory. Unfortunately, neither is a subset of the other:
5 Potential Games
Potential games were introduced by Monderer and Shapley (1996). It turns out that our definition of potential game above coincides with a special case of the potential games of Monderer and Shapley (1996), which they refer to as exact potential games.
for all and all , see Monderer and Shapley (1996).
If for all then equation (11) is equivalent to requiring that the Jacobian of the game is symmetric.
Proof In an exact potential game, the Jacobian coincides with the Hessian of the potential function , which is necessarily symmetric.
Monderer and Shapley (1996) refer to the special case where for all as an exact potential game. We use the shorthand ‘potential game’ to refer to exact potential games in what follows.
Potential games have been extensively studied since they are one of the few classes of games for which Nash equilibria can be computed (Rosenthal, 1973). For our purposes, they are games where simultaneous gradient descent on the losses corresponds to gradient descent on a single function. It follows that descent on converges to a fixed point that is a local minimum of or a saddle.
6 Hamiltonian Games
Hamiltonian games, where the Jacobian is antisymmetric, are a new class games. They are related to the harmonic games introduced in Candogan et al. (2011), see section B.4. An example from Balduzzi et al. (2018b) may help develop intuition for antisymmetric matrices:
Suppose competitors play one-on-one and that the probability of player beating player is . Then, assuming there are no draws, the probabilities satisfy and . The matrix of logits is then antisymmetric. Intuitively, antisymmetry reflects a hyperadversarial setting where all pairwise interactions between players are zero-sum.
Hamiltonian games are closely related to zero-sum games.
However, in general there are Hamiltonian games that are not zero-sum and vice versa.
Fix constants and and suppose players and minimize losses
with respect to and respectively.
The game actually has potential function .
Hamiltonian games are quite different from potential games. In a Hamiltonian game there is a Hamiltonian function that specifies a conserved quantity. In potential games the dynamics equal ; in Hamiltonian games the dynamics are orthogonal to . The orthogonality implies the conservation law that underlies the cyclic behavior in example 1.
Let . If the game is Hamiltonian then
and
preserves the level sets of since .
If the Jacobian is invertible and then gradient descent on converges to a stable fixed point.
Proof Direct computation shows for any game. The first statement follows since in Hamiltonian games.
For the second statement, the directional derivative is where since by anti-symmetry. It follows that .
For the third statement, gradient descent on will converge to a point where . If the Jacobian is invertible then clearly . The fixed-point is stable since in a Hamiltonian game, recall remark 1.
In fact, is a Hamiltonian function for the game dynamics, see appendix B for a concise explanation. We use the notation throughout the paper. However, can only be interpreted as a Hamiltonian function for when the game is Hamiltonian.
There is a precise mapping from Hamiltonian games to symplectic geometry, see appendix B. Symplectic geometry is the modern formulation of classical mechanics (Arnold, 1989; Guillemin and Sternberg, 1990). Recall that periodic behaviors (e.g. orbits) often arise in classical mechanics. The orbits lie on the level sets of the Hamiltonian, which expresses the total energy of the system.
Algorithms
We have seen that fixed points of potential and Hamiltonian games can be found by descent on and respectively. This section tackles finding stable fixed points in general games.
There are two classes of games where we know how to find stable fixed points: potential games where converges to a local minimum and Hamiltonian games where , which is orthogonal to , finds stable fixed points.
In the general case, the following desiderata provide a set of reasonable properties for an adjustment of the game dynamics. Recall that is the angle between the vectors and .
To find stable fixed points, an adjustment to the game dynamics should satisfy
compatibleTwo nonzero vectors are compatible if they have positive inner product. with game dynamics: ;
compatible with potential dynamics: if the game is a potential game then ;
compatible with Hamiltonian dynamics: If the game is Hamiltonian then ;
attracted to stable equilibria: in neighborhoods where , require ;
repelled by unstable equilibria: in neighborhoods where , require .
for some .
Desideratum does not guarantee that players act in their own self-interest – this requires a stronger positivity condition on dot-products with subvectors of , see Balduzzi (2017). Desiderata and imply that the adjustment behaves correctly in potential and Hamiltonian games respectively.
To understand desiderata and , observe that gradient descent on will find local minima that are fixed points of the dynamics. However, we specifically wish to converge to stable fixed points. Desideratum and require that the adjustment improves the rate of convergence to stable fixed points (by finding a steeper angle of descent), and avoids unstable fixed points.
More concretely, desiderata can be interpreted as follows. If points at a stable equilibrium then we require that points more towards the equilibrium (i.e. has smaller angle). Conversely, desiderata requires that if points away then the adjustment should point further away.
The unadjusted dynamics satisfies all the desiderata except .
2 Consensus Optimization
Since gradient descent on the function finds stable fixed points in Hamiltonian games, it is natural to ask how it performs in general games. If the Jacobian is invertible, then iff . Thus, gradient descent on converges to fixed points of .
However, there is no guarantee that descent on will find a stable fixed point. Mescheder et al. (2017) propose consensus optimization, a gradient adjustment of the form
Unfortunately, consensus optimization can converge to unstable fixed points even in simple cases where the ‘game’ is to minimize a single function:
Note that and
Descent on converges to the global maximum unless .
Although consensus optimization works well in two-player zero-sum, it cannot be considered a candidate algorithm for finding stable fixed points in general games since it fails in the basic case of potential games. Consensus optimization only satisfies desiderata and .
3 Symplectic Gradient Adjustment
The problem with consensus optimization is that it can perform worse than gradient descent on potential games. Intuitively, it makes bad use of the symmetric component of the Jacobian. Motivated by the analysis in section 2, we propose symplectic gradient adjustment, which takes care to only use the antisymmetric component of the Jacobian when adjusting the dynamics.
satisfies – for , with and .
Proof First claim: by anti-symmetry of . Second claim: in a potential game, so . Third claim: since by assumption. Note that desiderata and are true even when . This will prove useful, since example 9 shows that it may be necessary to pick negative near . Section 3.5 shows how to also satisfy desiderata and .
4 Convergence
We begin by analysing convergence of SGA near stable equilibria. The following lemma highlights that the interaction between the symmetric and antisymmetric components is important for convergence. Recall that two matrices and commute iff . That is, and commute iff . Intuitively, two matrices commute if they have the same preferred coordinate system.
If is symmetric positive semidefinite and commutes with then points towards stable fixed points for non-negative :
Proof First observe that , where the first equality holds since the expression is a scalar, and the second holds since and . It follows that if . Finally rewrite the inequality as
since and by positivity of , and .
The lemma suggests that in general the failure of and to commute should be important for understanding the dynamics of . We therefore introduce the additive condition number to upper-bound the worst-case noncommutativity of , which allows to quantify the relationship between and . If , then commutes with all matrices. The larger the additive condition number , the larger the potential failure of to commute with other matrices.
Let be a symmetric matrix with eigenvalues . The additive condition numberThe condition number of a positive definite matrix is . of is . If is positive semidefinite with additive condition number then implies
If is negative semidefinite, then implies
The inequalities are strict if is invertible.
Proof We prove the case ; the case is similar. Rewrite the inequality as
Since is positive semidefinite, there exists an upper-triangular square-root matrix such that and so . Further,
since . Putting the observations together obtains
Set and . We can continue the above computation
Finally, for any in the range , which is to say, for any . The kernel of and the kernel of coincide. If is in the kernel of , resp. , it cannot be in the kernel of , resp. and the term is positive. Otherwise, the term is positive.
Proof This is a standard result on fixed-point iterations, adapted from Ortega and Rheinboldt (2000, 10.1.3).
A matrix is called positive stable if all its eigenvalues have positive real part. Assume is a fixed point of a differentiable game such that is positive stable for in some set . Then SGA converges locally to for and sufficiently small.
Proof Let . By definition of fixed points, and so
is positive stable by assumption, namely has eigenvalues with . Writing for the iterative procedure given by SGA, it follows that
has eigenvalues , which are in the unit circle for small . More precisely,
which is always possible for . Hence has eigenvalues in the unit circle for , and we are done by Ostrowski’s Theorem since is a fixed point of .
Let be a stable fixed point and the additive condition number of . Then SGA converges locally to for all and sufficiently small.
Proof By Theorem 5 and the assumption that is a stable fixed point with invertible Jacobian, we know that
for . The proof does not rely on any particular property of , and can trivially be extended to the claim that
for all non-zero vectors . In particular this can be rewritten as
which implies positive definiteness of . A positive definite matrix is positive stable, and any matrices and have identical spectrum. This implies also that is positive stable, and we are done by the corollary above.
We conclude that SGA converges to an SFP if is small enough, where ‘small enough’ depends on the additive condition number.
5 Picking sign(λ)sign𝜆\operatorname*{sign}(\lambda)
This section explains desiderata – and shows how to pick to speed up convergence towards stable and away from unstable fixed points. In the example below, almost any choice of positive results in convergence to an unstable equilibrium. The problem arises from the combination of a weak repellor with a strong rotational force.
with an unstable equilibrium at . The dynamics are
which converges to the unstable equilibrium if .
We now show how to pick the sign of to avoid unstable equilibria. First, observe that . It follows that for :
A criterion to probe the positive/negative definiteness of is thus to check the sign of . The dot product can take any value if is neither positive nor negative (semi-)definite. The behavior near saddle points will be explored in Section 3.7.
Recall that desiderata requires that, if points at a stable equilibrium then we require that points more towards the equilibrium (i.e. has smaller angle). Conversely, desiderata requires that, if points away then the adjustment should point further away. More formally,
Let and be two vectors. The infinitesimal alignment of with a third vector is
If and point the same way, , then when bends further toward , see figure 2A. Otherwise when bends away from , see figure 2B.
The following lemma allows us to rewrite the infinitesimal alignment in terms of known (computable) quantities, from which we can deduce the correct choice of .
When is the symplectic gradient adjustment,
where the denominator has no linear term in because . It follows that the sign of the infinitesimal alignment is
Intuitively, computing the sign of provides a check for stable and unstable fixed points. Computing the sign of checks whether the adjustment term points towards or away from the nearby fixed point. Putting the two checks together yields a prescription for the sign of , as follows.
Desiderata – are satisfied for such that .
Proof If we are in a neighborhood of a stable fixed point then . It follows by lemma 11 that \operatorname*{sign}\Big{(}\operatorname*{align}(\boldsymbol{\xi}_{\lambda}),\nabla{\mathcal{H}})\Big{)}=\operatorname*{sign}\Big{(}\langle{\mathbf{A}}^{\intercal}\boldsymbol{\xi},\nabla{\mathcal{H}}\rangle\Big{)} and so choosing \operatorname*{sign}(\lambda)=\operatorname*{sign}\Big{(}\langle{\mathbf{A}}^{\intercal}\boldsymbol{\xi},\nabla{\mathcal{H}}\rangle\Big{)} leads to the angle between and being smaller than the angle between and , satisfying desideratum . The proof for the unstable case is similar.
Gradient descent is also known as the method of steepest descent. In general games, however, does not follow the steepest path to fixed points due to the ‘rotational force’, which forces lower learning rates and slows down convergence.
The following lemma provides some intuition about alignment. The idea is that, the smaller the cosine between the ‘correct direction’ and the ‘update direction’ , the smaller the learning rate needs to be for the update to stay in a unit ball, see figure 3.
If and are unit vectors with then for . In other words, ensuring that is closer to the origin than requires smaller learning rates as the angle between and gets larger.
Proof Check iff . The result follows.
The next lemma is a standard technical result from the convex optimization literature.
Finally, we show that increasing alignment helps speed convergence:
Suppose is convex and Lipschitz smooth with . Let where . Then the optimal step size is where , with
The proof of Theorem 15 adapts lemma 14 to handle the angle arising from the ‘rotational force’.
to obtain and as required.
Increasing the cosine with the steepest direction improves convergence. The alignment computation in algorithm 1 chooses to be positive or negative such that is bent towards stable (increasing the cosine) and away from unstable fixed points. Adding a small to the computation introduces a weak bias towards stable fixed points.
6 Aligned Consensus Optimization
The stability criterion in (36) also provides a simple way to prevent consensus optimization from converging to unstable equilibria. Aligned consensus optimization is
where in practice we set . Aligned consensus optimization satisfies desiderata D3–D5. However, it behaves strangely in potential games. Multiplying by the Jacobian is the ‘inverse’ of Newton’s method since for potential games the Jacobian of is the Hessian of the potential function. Multiplying by the Hessian increases the gap between small and large eigenvalues, increasing the (usual, multiplicative) condition number and slows down convergence. Nevertheless, consensus optimization works well in GANs (Mescheder et al., 2017), and aligned consensus may improve performance, see experiments below.
Dropping the first term from (48) yields a simpler update that also satisfies –. However, the resulting algorithm performs poorly in experiments (not shown), perhaps because it is attracted to saddles.
7 Avoiding Strict Saddles
How does SGA behave near saddles? We show that Symplectic Gradient Adjustment locally avoids strict saddles, provided that and are small and parameters are initialized with (arbitrarily small) noise. More precisely, let be the iterative optimization procedure given by SGA. Then every strict saddle has a neighbourhood such that has measure zero for small and .
Intuitively, the Taylor expansion around a strict saddle is locally dominated by the Jacobian at , which has a negative eigenvalue. This prevents convergence to for random initializations of near . The argument is made rigorous using the Stable Manifold Theorem following Lee et al. (2017).
It follows that if has at least one eigenvalue then has dimension at least . Since has tangent space at with codimension at least one, we conclude that has measure zero. This is central to proving that the set of nearby initial points which converge to a given strict saddle has measure zero. Since is initialized randomly, the following theorem is obtained.
SGA locally avoids strict saddles almost surely, for and small.
Proof Let a strict saddle and recall that SGA is given by
All terms involved are continuously differentiable and we have
by assumption that . Since all terms except are of order at least , is invertible for all sufficiently small. By the inverse function theorem, there exists a neighbourhood of such that is has a continuously differentiable inverse on . Hence restricted to is a diffeomorphism with fixed point .
By definition of strict saddles, has an eigenvalue with negative real part. It follows by continuity that also has an eigenvalue with for sufficiently small. Finally,
has an eigenvalue with
It follows that has codimension at least one, implying in turn that the local stable set has measure zero. We can now prove that
Now is , hence locally Lipschitz and thus preserves sets of measure zero, so that has measure zero for each . Countable unions of measure zero sets are still measure zero, so we conclude that also has measure zero. In other words, SGA converges to with zero probability upon random initialization of in .
Unlike stable and unstable fixed points, it is unclear how to avoid strict saddles using only alignment, that is, independently from the size of .
Experiments
We compare SGA with simultaneous gradient descent, optimistic mirror descent (Daskalakis et al., 2018) and consensus optimization (Mescheder et al., 2017) in basic settings.
We investigate the effect of SGA when a weak attractor is coupled to a strong rotational force:
Gradient descent is extremely sensitive to the choice of learning rate , top row of figure 4. As increases through gradient descent goes from converging extremely slowly, to diverging slowly, to diverging rapidly. SGA yields faster, more robust convergence. SGA converges faster with learning rates and , and only starts overshooting the fixed point for .
2 Basic adversarial games
Optimistic mirror descent is a family of algorithms that has nice convergence properties in games (Rakhlin and Sridharan, 2013; Syrgkanis et al., 2015). In the special case of optimistic gradient descent the updates are
The left panel shows the number of steps to convergence (when convergence occurs) over a range of learning rates. OMD’s peak performance is better than SGA, where the red curve dips below the blue. Howwever, we find that SGA converges – and does so faster – for a much wider range of learning rates. OMD diverges for learning rates not in the range [0.3, 1.2]. Simultaneous gradient descent oscillates without converging (not shown). The right panel shows the average performance of OMD and SGA on the last 10 steps. Once again, here SGA consistently performs better over a wider range of learning rates. Individual runs are shown in figure 6.
Figure 7 shows time to convergence (using the same convergence criterion as above) for optimistic mirror descent and SGA. The games are constructed with four players, each of which controls one parameter. The losses are
where in the left panel and in the right panel. The antisymmetric component of the game Jacobian is
OMD converges considerably slower than SGA across the full range of learning rates. It also diverges for learning rates . In contrast, SGA converges more quickly and robustly.
3 Learning a two-dimensional mixture of Gaussians
We apply SGA to a basic Generative Adversarial Network setup adapted from Metz et al. (2017). Data is sampled from a highly multimodal distribution designed to probe the tendency of GANs to collapse onto a subset of modes during training. The distribution is a mixture of 16 Gaussians arranged in a grid. Figure 8 shows the probability distribution that is sampled to train the generator and discriminator. The generator and discriminator networks both have 6 ReLU layers of 384 neurons. The generator has two output neurons; the discriminator has one.
Figure 9 shows results after iterations. The networks are trained under RMSProp. Learning rates were chosen by visual inspection of grid search results at iteration 8000. More precisely, grid search was over learning rates 1e-5, 2e-5,5e-5, 8e-5, 1e-4, 2e-4, 5e-4 and then a more refined linear search over 8e-5, 2e-4. Simultaneous gradient descent and SGA are shown in the figure.
The last two rows of figure 9 show the performance of consensus optimization without and with alignment. Introducing alignment slightly improves speed of convergence (second column) and final result (fourth column), although intermediate results in third column are ambiguous.
Simultaneous gradient descent exhibits mode collapse followed by mode hopping in later iterations (not shown). Mode hopping is analogous to the cycles in example 1. Unaligned SGA converges to the correct distribution; alignment speeds up convergence slightly. Consensus optimization performs similarly in this GAN example. However, consensus optimization can converge to local maxima even in potential games, recall example 8.
4 Learning a high-dimensional unimodal Gaussian
Mode collapse is a well-known phenomenon in GANs. A more subtle phenomenon, termed boundary distortion, was identified in Santurkar et al. (2018). Boundary distortion is a form of covariate shift where the generator fails to model the true data distribution.
Santurkar et al demonstrate boundary distortion using data sampled from a 75-dimensional unimodal Gaussian with spherical covariate matrix. Mode collapse is not a problem in this setting because the data distribution is unimodal. Nevertheless, they show that vanilla GANs fail to learn most of the spectrum of the covariate matrix.
Figure 10 reproduces their result. Panel A shows the ground truth: all 75 eigenvalues are equal to 1.0. Panel B shows the spectrum of the covariance matrix of the data generated by a GAN trained with RMSProp. The GAN concentrates on a single eigenvalue and essentially ignores the remaining 74 eigenvalues. This is similar to, but more extreme than, the empirical results obtained in Santurkar et al. (2018). We emphasize that the problem is not mode collapse, since the data is unimodal (although, it’s worth noting that most of the mass of a high-dimensional Gaussian lies on the “shell”).
Finally, panel C shows the spectrum of the covariance matrix of the data sampled from a GAN trained via SGA. The GAN approximately learns all the eigenvalues, with values ranging between 0.6 and 1.5.
Discussion
Modern deep learning treats differentiable modules like plug-and-play lego blocks. For this to work, at the very least, we need to know that gradient descent will find local minima. Unfortunately, gradient descent does not necessarily find local minima when optimizing multiple interacting objectives. With the recent proliferation of algorithms that optimize more than one loss, it is becoming increasingly urgent to understand and control the dynamics of interacting losses. Although there is interesting recent work on two-player adversarial games such as GANs, there is essentially no work on finding stable fixed points in more general games played by interacting neural nets.
The generalized Helmholtz decomposition provides a powerful new perspective on game dynamics. A key feature is that the analysis is indifferent to the number of players. Instead, it is the interplay between the simultaneous gradient on the losses and the symmetric and antisymmetric matrices of second-order terms that guides algorithm design and governs the dynamics under gradient adjustments.
Symplectic gradient adjustment is a straightforward application of the generalized Helmholtz decomposition. It is unlikely that SGA is the best approach to finding stable fixed points. A deeper understanding of the interaction between the potential and Hamiltonian components will lead to more effective algorithms. Reinforcement learning algorithms that optimize multiple objectives are increasingly common, and second-order terms are difficult to estimate in practice. Thus, first-order methods that do not use Jacobian-vector products are of particular interest.
Finally, it is worth raising a philosophical point. In this paper we are concerned with finding stable fixed points (because, for example, they yield pleasing samples in GANs). We are not concerned with the losses of the players per se. The gradient adjustments may lead to a player acting against its own self-interest by increasing its loss. We consider this acceptable insofar as it encourages convergence to a stable fixed point. The players are but a means to an end.
We have argued that stable fixed points are a more useful solution concept than local Nash equilibria for our purposes. However, neither is entirely satisfactory, and the question “What is the right solution concept for neural games?” remains open. In fact, it likely has many answers. The intrinsic curiosity module introduced by Pathak et al. (2017) plays two objectives against one another to drive agents to search for novel experiences. In this case, converging to a fixed point is precisely what is to be avoided.
It is remarkable – to give a few examples sampled from many – that curiosity, generating photorealistic images, and image-to-image translation (Zhu et al., 2017) can be formulated as games. What else can games do?
Acknowledgements.
We thank Guillaume Desjardins and Csaba Szepesvari for useful comments.
References
A TensorFlow code to compute SGA
Source code is available at https://github.com/deepmind/symplectic-gradient-adjustment. Since computing the symplectic adjustment is quite simple, we include an explicit description here for completeness.
The code requires a list of losses, , and a list of variables for the players, . The function fwd_gradients which implements forward mode auto-differentiation is in the module tf.contrib.kfac.utils.
% compute Jacobian-vector product
% compute Jacobian⊺-vector product
% compute Symplectic Gradient Adjustment
B Helmholtz, Hamilton, Hodge, and Harmonic games
This section explains the mathematical connections with the Helmholtz decomposition, symplectic geometry and the Hodge decomposition. The discussion is not necessary to understand the main text. It is also not self-contained. The details can be found in textbooks covering differential and symplectic geometry (Arnold, 1989; Guillemin and Sternberg, 1990; Bott and Tu, 1995).
The classical Helmholtz decomposition states that any vector field in 3-dimensions is the sum of curl-free (gradient) and divergence-free (infinitesimal rotation) components:
We explain the link between curl and the antisymmetric component of the game Jacobian. Recall that gradients of functions are actually differential 1-forms, not vector fields. Differential 1-forms and vector fields on a manifold are canonically isomorphic once a Riemannian metric has been chosen. In our case, we are implicitly using the Euclidean metric. The antisymmetric matrix is the differential 2-form obtained by applying the exterior derivative to the 1-form .
In 3-dimensions, the Hodge star operator is an isormorphism from differential 2-forms to vector fields, and the curl can be reformulated as . In claiming is analogous to curl, we are simply dropping the Hodge-star operator.
Finally, recall that the Lie algebra of infinitesimal rotations in -dimensions is given by antisymmetric matrices. When , the Lie algebra can be represented as vectors (three numbers specify a antisymmetric matrix) with the -product as Lie bracket. In general, the antisymmetric matrix captures the infinitesimal tendency of to rotate at each point in the parameter space.
B.2 Hamiltonian Mechanics
The function is then referred to as the Hamiltonian function of the vector field. In our case, the antisymmetric matrix is a closed 2-form because and . It may however be degenerate. It is therefore a presymplectic form (Bottacin, 2005).
Setting , equation (58) can be rewritten in our notation as
justifying the terminology ‘Hamiltonian’.
B.3 The Hodge Decomposition
The exterior derivative is a linear operator that takes differential -forms on a manifold , , to differential -forms, . In the case , the exterior derivative is the gradient, which takes 0-forms (that is, functions) to 1-forms. Given a Riemannian metric, the adjoint of the exterior derivative goes in the opposite direction. Hodge’s theorem states that -forms on a compact manifold decompose into a direct sum over three types:
Setting , we recover a decomposition that closely resembles the generalized Helmholtz decomposition:
B.4 Harmonic and Potential Games
Candogan et al. (2011) derive a Hodge decomposition for games that is closely related in spirit to our generalized Helmholtz decomposition – although the details are quite different. Candogan et al. (2011) work with classical games (probability distributions on finite strategy sets). Their losses are multilinear, which is easier than our setting, but they have constrained solution sets, which is harder in many ways. Their approach is based on combinatorial Hodge theory (Jiang et al., 2011) rather than differential and symplectic geometry. Finding a best-of-both-worlds approach that encompasses both settings is an open problem.
C Type Consistency
The next two sections carefully work through the units in classical mechanics and two-player games respectively. The third section briefly describes a use-case for type consistency.
where is position, is momentum, is mass, is surface tension and measures energy. The units (denoted by ) are
where is meters, is kilograms and is seconds. Energy is measured in joules, and indeed it is easy to check that .
Note that the units for differentation by are . For example, differentiating by time has units . Hamilton’s equations state that and where
The resulting flow describing the dynamics of the system is
with units . Hamilton’s equations can be reformulated more abstractly via symplectic geometry. Introduce the symplectic form
Observe that contracting the flow with the Hamiltonian obtains
with units .
Although there is no notion of “loss” in classical mechanics, it is useful (for the next section) to keep pushing the formal analogy. Define the “losses”
The duality between vector fields and differential forms.
Finally recall that the symplectic form in games was not “pulled out of thin air” as , but rather derived as , where is the differential form corresponding to the vector field under the musical isomorphism .
It is instructive to compute in the case of a classical mechanical system and see what happens. Naively, we would guess that the musical isomorphism is and . However, applying the naive musical isomorphism to to get
and we cannot add objects with different types.
To correct the type inconsistency, define the musical isomorphism as
The correction terms in the direction invert the coupling terms and that were originally introduced into the Hamiltonian for physical reasons. Applying the corrected musical isomorphism to yields
The two terms of then have coherent types
which recovers the symplectic form (up to sign) with units as required. Finally, observe that
C.2 Units in Two-Player Games
Without loss of generality let where we refer to as position and as momentum so that and . The aim of this section is to check type-consistency under these, rather arbitrarily assigned, units. Since we are considering a game, we do not require that and have the same dimension – even though this would necessarily be the case for a physical system. The goal is to verify that units can be consistently assigned to games.
Consider a quadratic two player game of the form
The presymplectic form makes use of the musical isomorphism . As in section C.1, if we naively define and then
It is necessary, as in section C.1, to correct the naive musical isomorphism by taking into account the coupling constants for the mixed position-momentum terms. In the classical setup the coupling constants were the scalars and , whereas in a game they are the off-diagonal blocks and .
Apply singular value decomposition to factorize
where the entries of the diagonal matrices have types and , and the types of the orthogonal matrices and are pure scalars. The diagonal matrices and have the same types as and in the classical system since they play the same coupling role.
Extending the procedure adopted in the section C.1, fix the type-inconsistency by defining the musical isomorphisms as
Alternatively, the isomorphisms can be computed by noting that and .
The dual isomorphism is then
where the notation emphasizes that the two-form is type-consistent.
C.3 What Does Type-Consistency Buy?
Although is not a potential field, there is a family of functions on which performs gradient descent – albeit with coordinate-wise learning rates that may not be optimal. The vector field arguably does not require adjustment. This kind of situation often arises when the learning rates of different parameters are set adaptively during training of neural nets, by rescaling them by positive numbers.
The vanilla and type-consistent 1-forms corresponding to are, respectively,
It follows that the type-consistent symplectic gradient adjustment is zero. Type-consistency ‘detects’ that no gradient adjustment is needed in example 10.