T AMING GAN S WITH L OOKAHEAD –M INMAX
Anonymous authors
Paper under double-blind review
A BSTRACT
Generative Adversarial Networks are notoriously challenging to train.
The underlying minmax optimization is highly susceptible to the variance of the stochastic gradient and the rotational component of the associated game vector ﬁeld.
To tackle these challenges, we propose the Lookahead algorithm for minmax optimization, originally developed for single objective minimization only.
The backtracking step of our Lookahead–minmax naturally handles the rotational game dynamics, a property which was identiﬁed to be key for enabling gradient ascent descent methods to converge on challenging examples often analyzed in the literature.
Moreover, it implicitly handles high variance without using large mini-batches, known to be essential for reaching state of the art performance.
Experimental results on MNIST,
SVHN, CIFAR-10, and ImageNet demonstrate a clear advantage of combining
Lookahead–minmax with Adam or extragradient, in terms of performance and improved stability, for negligible memory and computational cost.
Using 30-fold fewer parameters and 16-fold smaller minibatches we outperform the reported performance of the class-dependent BigGAN on CIFAR-10 by obtaining FID of 12 . 19 without using the class labels, bringing state-of-the-art GAN training within reach of common computational resources.
I NTRODUCTION
Gradient-based methods are the workhorse of machine learning.
These methods optimize the parameters of a model with respect to a single objective f : X ! R .
However, an increasing interest for multi-objective optimization arises in various domains—such as mathematics, economics, multiagent reinforcement learning (Omidshaﬁei et al., 2017)—where several agents aim at optimizing their own cost function
f
i : X 1 ⇥ · · · ⇥ X N !
R simultaneously.
A particularly successful class of algorithms of this kind are the Generative Adversarial Networks (Goodfellow et al., 2014, (GANs)), which consist of two players referred to as a generator and a discriminator.
GANs were originally formulated as minmax optimization f : X ⇥ Y !
R (Von Neumann & Morgenstern, 1944), where the generator and the discriminator aim at minimizing and maximizing the same value function, see § 2.
A natural generalization of gradient descent for minmax problems is the gradient descent ascent algorithm (GDA), which alternates between a gradient descent step for the min-player and a gradient ascent step for the max-player.
This minmax training aims at ﬁnding a Nash equilibrium where no player has the incentive of changing its parameters.
Despite the impressive quality of the samples generated by the GANs—relative to classical maximum likelihood-based generative models—these models remain notoriously difﬁcult to train .
In particular, poor performance (sometimes manifesting as “mode collapse”), brittle dependency on hyperparameters, or divergence are often reported.
Consequently, obtaining state-of-the-art performance was shown to require large computational resources (Brock et al., 2019), making well-performing models unavailable for common computational budgets.
It was recently empirically shown that: (i) GANs often converge to a locally stable stationary point that is not a differential Nash equilibrium (Berard et al., 2020); (ii) increased batch size improves
GAN performances (Brock et al., 2019) in contrast to minimization (Defazio & Bottou, 2019; Shallue et al., 2018).
A principal reason behind these differences is attributed to the rotations arising due to the adversarial component of the associated vector ﬁeld of the gradient of the two player’s parameters (Mescheder et al., 2018;
Balduzzi et al., 2018), which are atypical for minimization.
More precisely, the Jacobian of the associated vector ﬁeld (see deﬁnition in § 2) can be decomposed into a
[Figure]
symmetric and antisymmetric component (Balduzzi et al., 2018), which behave as a potential (Monderer & Shapley, 1996) and a Hamiltonian game, resp.
Games are often combination of the two, making this general case hard to solve.
In the context of single objective minimization
Zhang et al.
(2019) recently proposed the Lookahead algorithm, which intuitively uses an update direction by “looking ahead” at the sequence of parameters that change with higher variance due to the “stochasticity” of the gradient estimates–called fast weights–generated by an inner optimizer 1 .
Lookahead was shown to improve the stability during training and to reduce the variance of the so called slow weights.
Contributions.
Our contributions can be summarized as follows:
• Building on insights of Wang et al.
(2020), who argue that Lookahead can be interpreted as an instance of local SGD, we derive improved convergence guarantees for the Lookahead algorithm in the context of single objective minimization.
• We propose Lookahead–minmax for optimizing minmax problems, that applies extrapolation in the joint parameter space (see Alg 1), so as to account for the rotational component of the associated game vector ﬁeld (deﬁned in § 2).
• We motivate the use of Lookahead–minmax for games by considering the extensively studied toy bilinear example (Goodfellow, 2016) and show that: (i) the use of lookahead allows for convergence of the otherwise diverging GDA on the classical bilinear game in full-batch setting (see § 4.1.1), as well as (ii) it yields good performance on challenging stochastic variants of this game, despite the high variance (see § 4.1.2).
• We empirically benchmark Lookahead–minmax on GANs on four standard datasets— MNIST, CIFAR-10, SVHN and ImageNet— on two different models (DCGAN & ResNet), with standard optimization methods for GANs, GDA and Extragradient, called LA–AltGAN and LA–ExtraGradient, resp.
We consistently observe both stability and performance improvements at a negligible additional cost that does not require additional forward and backward passes, see § 5.
B ACKGROUND
GAN formulation.
Given the data distribution p d , the generator is a mapping G : z 7! x , where z is sampled from a known distribution z ⇠ p z and ideally x ⇠ p d .
The discriminator D : x 7!
D ( x ) 2 [0 , 1] is a binary classiﬁer whose output represents a conditional probability estimate that an x sampled from a balanced mixture of real data from p d and G -generated data is actually real.
The optimization of a GAN is formulated as a differentiable two-player game where the generator G with parameters ✓ , and the discriminator D with parameters ' , aim at minimizing their own cost function L ✓ and L ' , respectively, as follows:
[Equation]
When L ' =
L ✓ the game is called a zero-sum and equation 2P-G is a minmax problem.
Minmax optimization methods.
As GDA does not converge for some simple convex-concave game, Korpelevich (1976) proposed the extragradient method, where a “prediction” step is performed to obtain an extrapolated point ( ✓ t + 12 , ' t + 12 ) using GDA, and the gradients at the extrapolated point are then applied to the current iterate ( ✓ t , ' t ) as follows:
Extrapolation
[Equation]
where ⌘ denotes the step size.
In the context of zero-sum games, the extragradient method converges for any convex-concave function L and any closed convex sets ⇥ and  (Facchinei & Pang, 2003).
The joint vector ﬁeld.
Mescheder et al.
(2017) and Balduzzi et al.
(2018) argue that the vector ﬁeld obtained by concatenating the gradients of the two players gives more insights of the dynamics than studying the loss surface.
The joint vector ﬁeld (JVF) and the Jacobian of JVF are deﬁned as:
[Equation]
✓ , ' ) ◆ , and v 0 ( ✓ ,
[Equation]
[Equation]
Rotational component of the game vector ﬁeld.
Berard et al.
(2020) show empirically that GANs converge to a locally stable stationary point (Verhulst, 1990, LSSP) that is not a differential Nash equilibrium–deﬁned as a point where the norm of the Jacobian is zero and where the Hessian of both the players are deﬁnite positive .
LSSP is deﬁned as a point ( ✓ ? , ' ? )
where:
[Equation]
where Sp ( · ) denotes the spectrum of v 0 ( · ) and R ( · ) the real part.
In summary, (i) if all the eigenvalues of v 0 ( ✓ t , ' t ) have positive real part the point ( ✓ t , ' t ) is LSSP, and (ii)
if the eigenvalues of v 0 ( ✓ t , ' t ) have imaginary part, the dynamics of the game exhibit rotations.
Impact of noise due to the stochastic gradient estimates on games.
Chavdarova et al.
(2019) point out that relative to minimization, noise impedes more the game optimization, and show that there exists a class of zero-sum games for which the stochastic extragradient method diverges .
Intuitively, bounded noise of the stochastic gradient hurts the convergence as with higher probability the noisy gradient points in a direction that makes the algorithm to diverge from the equilibrium, due to the properties of v 0 ( · ) (see Fig.1, Chavdarova et al., 2019).
L OOKAHEAD FOR SINGLE OBJECTIVE
In the context of single objective minimization, Zhang et al.
(2019) recently proposed the Lookahead algorithm where at every step t : (i) a copy of the current iterate ˜ !
t is made: ˜ !
t !
t , (ii) ˜ !
t is then updated for k  1 times yielding ˜ !
t + k , and ﬁnally (iii) the actual update !
t +1 is obtained as a point that lies on a line between the two iterates : the current !
t and the predicted one ˜ !
t + k :
[Equation]
t +
[Equation]
where ↵ 2 [0 , 1] .
(LA)
Lookahead uses two additional hyperparameters: (i) k –the number of steps used to obtain the prediction ˜ !
t + k , as well as (ii) ↵ – that controls how large a step we make towards the predicted iterate ˜ !
: the larger the closest, and when ↵ = 1 equation LA is equivalent to regular optimization (has no impact).
Besides the extra hyperparameters, LA was shown to help the used optimizer to be more resilient to the choice of its hyperparameters, achieve faster convergence across different tasks, as well as to reduce the variance of the gradient estimates (Zhang et al., 2019).
✓
3: for
1 do 4: k  1 do 5:
Sample x , z ⇠ p d , p z 6: ˜ ' t,i +1 =
˜ ' t,i  ⌘ ' d ' t,i (˜ ✓ t,i , ˜ ' t,i , x , z ) 7:
Sample z ⇠ p z 8: ˜ ✓ t,i +1 =
˜ ✓ t,i +1  ⌘ ✓ d ✓ t,i (˜ ✓ t,i , ˜ ' t,i , z ) 9: end for 10: ' t +1 = ' t + ↵ ' ( ˜ ' t,k  ' t ) 11: ✓ t +1 =
✓ t + ↵ ✓ (˜ ✓ t,k  ✓ t ) 12: ˜ ✓ t +1 , 0 , ˜ ' t +1 ,✓ t +1 , ' t +1 13: end for 14: Output: ✓ T , ' T
[Figure]
See § 4.1.1.
Theoretical Analysis.
The theoretical understanding of the LA optimizer (in the variant where k
SGD steps are used for prediction) is still under development: Zhang et al.
(2019) study the performance of LA on quadratic functions and Wang et al.
(2020) recently provided an analysis for general smooth non-convex functions.
One of their main observations is that LA can be viewed as an instance of local SGD (or parallel SGD, Stich, 2019; Koloskova et al., 2020;
Woodworth et al., 2020b).
Relying on the insights developed in these works, we can further improve upon the results by Wang et al.
(2020), and we show in Appendix A that the number of gradient updates for converging to a stationary point E kr f ( ! )
k 2  " , assuming stochastic gradient variance bounded by  2 , can be bounded as:
LA on smooth f : O
[Equation]
The asymptotically most signiﬁcant term, O   2 " , of matches with the corresponding term in the SGD convergence rate for all choices of ↵ 2 (0 , 1] , and when ↵ ! 1 , the same convergence guarantees as for SGD can be attained.
When  2 =
the rate improves to O  1 ✏  , in contrast to O  1 ✏ in (Wang et al., 2020).
For small values of ↵ , the worst-case complexity estimates of LA can in general be k times worse than for SGD (except for quadratic functions, where the rates match).
Deriving tighter analyses for LA that corroborate the observed practical advantages is still an open problem.
L OOKAHEAD FOR MINMAX OBJECTIVES
Although the simplistic bilinear game does not capture all the challenges of minmax optimization, it is instructive to consider it in order to understand the behavior of the optimizers around stationary points.
In this bilinear game, taking a point on a line between two points on a cyclic trajectory would reduce the distance to the optimum—as illustrated in Fig.
1—what motivates the extension of Lookahead on games.
Thus we use equation LA in joint parameter space ( ✓ , ' ) .
Alg. 1 summarizes the proposed Lookahead–minmax algorithm which for clarity does not cover different update ratios for the two players–see Alg.
3 for this case.
At every step t = 1 , . . .
, T , we ﬁrst compute k-step “predicted” iterates ( ˜ ✓ t,k , ˜ ' t,k ) —also called fast weights—using an inner “base” optimizer whose updates for the two players are denoted with d ' and d ✓ . For GDA and EG we have: [Equation] where for the latter, ' t,i + 12 , ✓ t,i + 12 are computed using equation EG.
The above updates can be combined with Adam (Kingma & Ba, 2015), see § D for detailed descriptions of these algorithms.
The so called slow weights ✓ t +1 , ' t +1 are then obtained as a point on a line between ( ✓ t , ' t ) and (˜ ✓ t,k , ˜ ' t,k ) — i.e. equation LA, see lines 10 & 11 (herein called backtracking or LA–step).
When combined with GDA, Alg. 1 can be equivalently re-written as Alg. 3, and note that it differs from using Lookahead separately per player–see § D.2.
Moreover, Alg. 1 can be applied several times using nested LA–steps with (different) k , see Alg. 6.
4. M OTIVATING EXAMPLE : THE BILINEAR GAME
We argue that Lookahead-minmax allows for improved stability and performance on minmax problems due to two main reasons: (i) it handles well rotations, as well as (ii) it reduces the noise due to making more conservative steps.
In the following, we disentangle the two, and show in § 4.1.
that Lookahead-minmax converges fast in the full-batch setting, without presence of noise as each parameter update uses the full dataset.
Moreover, besides that the GDA algorithm is known to diverge on this example, we show that when combined with lookahead it does converge.
In § 4.1.2 we consider the challenging problem of Chavdarova et al.
(2019), designed to have high variance.
We show that besides therein proposed Stochastic Variance Reduced Extragradient (SVRE),
Lookahead-minmax is the only method that converges on this experiment, while considering all methods of Gidel et al.
(2019a, §7.1).
More precisely, we consider the following bilinear problem:
[Equation]
with ✓ , ' , b i , c i 2 R d and A 2 R n ⇥ d ⇥ d , n = d =100 , and we draw [ A i ] kl =  kli and [ b i ] k , [ c i ] k
⇠
N (0 , 1 /d ) , 1  k, l  d , where  kli =1 if k = l = i , and 0 otherwise.
As one pass we count a forward and backward pass § B.4, and all results are normalized.
See § B.1 for hyperparameters.
4.1. T HE FULL - BATCH SETTING
In Fig.
3 we compare: (i) GDA with learning rate ⌘ = 10  4 and ⌘ = 0 .
3 (in blue), which oscilates around the optimum with small enough step size, and diverges otherwise; (ii) Unroll-Y where the max-player is unrolled k steps, before updating the min player, as in (Metz et al., 2017); (iii) Unroll-XY where both the players are unrolled k steps with ﬁxed opponent, and the actual updates are done with un unrolled opponent (see § B); (iv) LA–GDA with ↵ = 0 .
5 and ↵ = 0 .
4 (in red and pink, resp.) which combines Alg. 1 with GDA.
(v) ExtraGradient –Eq.
EG; as well as (vi) LA–ExtraGrad , which combines Alg. 1 with ExtraGradient.
See § B for description of the algorithms and their [Figure] D i s t a n ce t o t
h e o p t i m u m
[Figure] [Figure] [Figure] [Figure]
[Figure]
[Table]
[Table]
implementation.
Interestingly, we observe that Lookahead–Minmax allows GDA to converge on this example, and moreover speeds up the convergence of ExtraGradient.
4.1. T HE STOCHASTIC SETTING
In this section, we show that besides SVRE, Lookahead–minmax also converges on equation SB–G.
In addition, we test all the methods of Gidel et al. (2019a, §7.1) using minibatches of several sizes
B = 1 , 16 , 64 , and sampling without replacement.
In particular, we tested: (i) the Adam method combined with GDA (shown in blue); (ii) ExtraGradient –Eq.
EG; as well as (iii) ExtraAdam proposed by (Gidel et al., 2019a); (iv) our proposed method LA-GDA (Alg. 1) combined with GDA; as well as (v) SVRE (Chavdarova et al., 2019, Alg. 1 ) for completeness.
Fig.
4 depicts our results.
See § B for details on the implementation and choice of hyperparameters.
We observe that besides the good performance of LA-GDA on games in the batch setting, it also has the property to cope well large variance of the gradient estimates, and it converges without using restarting.
E XPERIMENTS
In this section, we empirically benchmark Lookahead–minmax–Alg. 1 for training GANs .
For the purpose of fair comparison, as an iteration we count each update of both the players, see Alg. 3.
5. E XPERIMENTAL SETUP Datasets.
We used the following image datasets: (i) MNIST (Lecun & Cortes, 1998), (ii) CIFAR-10 (Krizhevsky, 2009, §3), (iii) SVHN (Netzer et al., 2011), and (iv) ImageNet ILSVRC 2012 (Russakovsky et al., 2015), using resolution of 28 ⇥ 28 for MNIST , and 3 ⇥ 32 ⇥ 32 for the rest.
Metrics.
We use Inception score (IS, Salimans et al., 2016) and Fréchet Inception distance (FID, Heusel et al., 2017) as these are most commonly used metrics for image synthesis, see § E.1 for details.
On datasets other than ImageNet, IS is less consistent with the sample quality (see E.1.1).
DNN architectures.
For experiments on MNIST , we used the DCGAN architectures (Radford et al., 2016), described in § E.2.1.
For SVHN and CIFAR-10, we used the ResNet architectures, replicating the setup in (Miyato et al., 2018; Chavdarova et al., 2019), described in detail in E.2.2.
Optimization methods.
We use: (i) AltGan: the standard alternating GAN, (ii) ExtraGrad: the extragradient method, as well as (iii) UnrolledGAN: (Metz et al., 2017).
We combine Lookaheadminmax with (i) and (ii), and we refer to these as LA–AltGAN and LA–ExtraGrad , respectively or for both as LA–GAN for brevity.
We denote nested LA–GAN with preﬁx NLA , see § D.1.
All methods in this section use Adam (Kingma & Ba, 2015).
We compute Exponential Moving Average (EMA, see def.
in § C) of both the fast and slow weights–called EMA and EMA–slow , resp.
See
Appendix for results of uniform iterate averaging and RAdam (Liu et al., 2020).
5. R ESULTS AND D ISCUSSION Comparison with baselines.
Table 1 summarizes our comparison of combining Alg. 1 with
AltGAN and ExtraGrad.
On all datasets, we observe that the iterates (column “no avg”) of LA–
AltGAN and LA–ExtraGrad perform notably better than the corresponding baselines, and using
EMA on LA–AltGAN and LA–ExtraGrad further improves the FID and IS scores obtained with
LA–AltGAN.
As the performances improve after each LA–step, see Fig.
2 computing EMA solely on the slow weights further improves the scores.
It is interesting to note that on most of the datasets, the scores of the iterates of LA–GAN (column no-avg ) outperform the EMA scores of the respective baselines.
In some cases, EMA for AltGAN does not provide improvements, as the iterates diverge relatively early.
In our baseline experiments, ExtraGrad outperforms AtlGAN–while requiring twice the computational time of the latter per iteration.
The addition of Lookahead–minimax stabilizes
AtlGAN making it competitive to LA–ExtraGrad while using half of the computational time.
In Table 3 we report our results on MNIST, where–different from the rest of the datasets–the training of the baselines is stable, to gain insights if LA–GAN still yields improved performances.
The best
FID scores of the iterates (column “no avg”) are obtained with LA–GAN.
Interestingly, although we obtain that the last iterates are not LSSP (which could be due to stochasticity), from Fig.
5–which depicts the eigenvalues of JVF, we observe that after convergence LA–GAN shows no rotations.
[Figure] [Figure]
[Table]
Benchmark on CIFAR-10 using reported results.
Table 2 summarizes the recently reported best obtained FID and IS scores on CIFAR-10.
Although using the class labels–Conditional GAN is known to improve GAN performances (Radford et al., 2016), we outperform BigGAN (Brock et al., 2019) on CIFAR-10.
Notably, our model and BigGAN have 5 .
1 M and 158 .
3 M parameters in total, respectively, and we use minibatch size of 128 , whereas BigGAN uses 2048 samples.
The competitive result of (Yazıcı et al., 2019) of average 12 .
FID uses ⇠ 3 . 5 times larger model than ours and is omitted from Table 2 as it does not use the standard metrics pipeline. [Figure] [Figure]
Additional memory & computational cost.
Lookahead-minmax requires the same extra memory footprint as EMA and uniform averaging (one additional set of parameters per player)—both of which are updated each step whereas LA–GAN is updated once every k iterations.
On the choice of ↵ and k .
We ﬁxed ↵ = 0 .
5 , and we experimented with several values of k –while once selected, keeping k ﬁxed throughout the training.
We observe that all values of k improve the baseline.
Using larger k in large part depends on the stability of the base-optimizer: if it quickly diverges, smaller k is necessary to stabilize the training.
Thus we used k = 5 and k = 5000 for LA–
AltGAN and LA–ExtraGrad, resp.
When using larger values of k we noticed that the obtained scores would periodically drastically improve every k iterations–after an LA step, see Fig.2.
Interestingly, complementary to the results of (Berard et al., 2020)–who locally analyze the vector ﬁeld, Fig.
conﬁrms the presence of rotation while taking into account the used optimizer , and empirically validates the geometric justiﬁcation of Lookahead–minmax illustrated in Fig.1.
The necessity of small k for unstable baselines motivates nested LA–Minmax using two different values of k , of which one is relatively small (the inner LA–step) and the other is larger (the outer LA–step).
Intuitively, the inner and outer LA–steps in such nested LA–GAN tackle the variance and the rotations, resp.
Stability of convergence.
Fig.
6 shows that LA–GAN consistently improved the stability of its respective baseline .
Despite using 1 : 5 update ratio for G : D –known to improve stability, our baselines always diverge (also reported by Chavdarova et al., 2019; Brock et al., 2019).
On the other hand, LA–GAN diverged only few times and notably later in the training relative to the same baseline, see additional results in § F.
The stability further improves using nested LA–steps as in Fig.2.
R ELATED WORK
Parameter averaging.
In the context of convex single-objective optimization, taking an arithmetic average of the parameters as by Polyak & Juditsky (1992); Ruppert (1988) is well-known to yield faster convergence for convex functions and allowing the use of larger constant step-sizes in the case of stochastic optimization (Dieuleveut et al., 2017).
It recently gained more interest in deep learning in general (Garipov et al., 2018), in natural language processing (Merity et al., 2018), and particularly in GANs (Yazıcı et al., 2019) where researchers report the performance of a uniform or exponential moving average of the iterates.
Such averaging as a post-processing after training is fundamentally different from immediately applying averages during training.
Lookahead as of our interest here in spirit is closer to extrapolation methods (Korpelevich, 1976) which rely on gradients taken not at the current iterate but at an extrapolated point for the current trajectory.
For highly complex optimization landscapes such as in deep learning, the effect of using gradients at perturbations of the current iterate has a desirable smoothing effect which is known to help training speed and stability in the case of non-convex single-objective optimization (Wen et al., 2018; Haruki et al., 2019).
GANs
Several proposed methods for GANs are motivated by the “recurrent dynamics”.
Apart from the already introduced works, (i)
Yadav et al.
(2018) use prediction steps, (ii) Daskalakis et al.
(2018) propose Optimistic Mirror Decent (OMD) for training Wasserstein GANs (Arjovsky et al., 2017), (iii) Balduzzi et al.
(2018) propose the Symplectic Gradient Adjustment (SGA), among others.
Besides its simplicity, the key beneﬁt of LA–GAN is that it handles well both the rotations of the vector ﬁeld as well as noise from stochasticity, thus performing well on real-world applications.
C ONCLUSION
Motivated by the adversarial component of games and the negative impact of noise on games we proposed an extension of the Lookahead algorithm to games, called “Lookahead–minmax”.
On the bilinear toy example we observe that combining Lookahead–minmax with standard gradient methods converges, and that Lookahead–minmax copes very well with the high variance of the gradient estimates.
Exponential moving averaging of the iterates is known to help obtain improved performances for GANs, yet it does not impact the actual iterates, hence does not stop the algorithm from (early) divergence.
Lookahead–minmax goes beyond such averaging, requires less computation than running averages, and it is straightforward to implement .
It can be applied to any optimization method, and in practice it consistently improves the stability of its respective baseline.
While we do not aim at obtaining a new state-of-the-art result, it is remarkable that Lookahead–minmax obtains competitive result on CIFAR–10 of 12 .
19 FID–outperforming the 30 –times larger BigGAN.
As Lookahead–minmax uses two additional hyperparameters, future directions include developing adaptive schemes of obtaining these coefﬁcients throughout training, which could further speed up the convergence of Lookahead–minmax.