Loss Surfaces, Mode Connectivity, and Fast Ensembling of DNNs

Timur Garipov, Pavel Izmailov, Dmitrii Podoprikhin, Dmitry Vetrov, Andrew Gordon Wilson

Introduction

The loss surfaces of deep neural networks (DNNs) are highly non-convex and can depend on millions of parameters. The geometric properties of these loss surfaces are not well understood. Even for simple networks, the number of local optima and saddle points is large and can grow exponentially in the number of parameters . Moreover, the loss is high along a line segment connecting two optima [e.g., 8, 17]. These two observations suggest that the local optima are isolated.

The left panel shows a plane defined by three independently trained networks. In this plane, all optima are isolated, which corresponds to the standard intuition. However, the middle and right panels show two different paths of near-constant loss between the modes in weight space, discovered by our proposed training procedure. The endpoints of these paths are the two independently trained DNNs corresponding to the two lower modes on the left panel.

We believe that this geometric discovery has major implications for research into multilayer networks, including (1) improving the efficiency, reliability, and accuracy of training, (2) creating better ensembles, and (3) deriving more effective posterior approximation families in Bayesian deep learning. Indeed, in this paper we are inspired by this geometric insight to propose a new ensembling procedure that can efficiently discover multiple high-performing but diverse deep neural networks.

In particular, our contributions include:

The discovery that the local optima for modern deep neural networks are connected by very simple curves, such as a polygonal chain with only one bend.

A new method that finds such paths between two local optima, such that the train loss and test error remain low along these paths.

Using the proposed method we demonstrate that such mode connectivity holds for a wide range of modern deep neural networks, on key benchmarks such as CIFAR-100. We show that these paths correspond to meaningfully different representations that can be efficiently ensembled for increased accuracy.

Inspired by these observations, we propose Fast Geometric Ensembling (FGE), which outperforms the recent state-of-the-art Snapshot Ensembles , on CIFAR-10 and CIFAR-100, using powerful deep neural networks such as VGG-16, Wide ResNet-28-10, and ResNet-164. On ImageNet we achieve 0.56%0.56\% top-11 error-rate improvement for a pretrained ResNet-50 model by running FGE for only 55 epochs.

We release the code for reproducing the results in this paper at https://github.com/timgaripov/dnn-mode-connectivity

The rest of the paper is organized as follows. Section 2 discusses existing literature on DNN loss geometry and ensembling techniques. Section 3 introduces the proposed method to find the curves with low train loss and test error between local optima, which we investigate empirically in Section 4. Section 5 then introduces our proposed ensembling technique, FGE, which we empirically compare to the alternatives in Section 6. Finally, in Section 7 we discuss connections to other fields and directions for future work.

Note that we interleave two sections where we make methodological proposals (Sections 3, 5), with two sections where we perform experiments (Sections 4, 6). Our key methodological proposal for ensembling, FGE, is in Section 5.

Related Work

Despite the success of deep learning across many application domains, the loss surfaces of deep neural networks are not well understood. These loss surfaces are an active area of research, which falls into two distinct categories.

The first category explores the local structure of minima found by SGD and its modifications. Researchers typically distinguish sharp and wide local minima, which are respectively found by using large and small mini-batch sizes during training. Hochreiter and Schmidhuber and Keskar et al. , for example, claim that flat minima lead to strong generalization, while sharp minima deliver poor results on the test dataset. However, recently Dinh et al. argue that most existing notions of flatness cannot directly explain generalization. To better understand the local structure of DNN loss minima, Li et al. proposed a new visualization method for the loss surface near the minima found by SGD. Applying the method for a variety of different architectures, they showed that the loss surfaces of modern residual networks are seemingly smoother than those of VGG-like models.

The other major category of research considers global loss structure. One of the main questions in this area is how neural networks are able to overcome poor local optima. Choromanska et al. investigated the link between the loss function of a simple fully-connected network and the Hamiltonian of the spherical spin-glass model. Under strong simplifying assumptions they showed that the values of the investigated loss function at local optima are within a well-defined bound. In other research, Lee et al. showed that under mild conditions gradient descent almost surely converges to a local minimizer and not a saddle point, starting from a random initialization.

In recent work Freeman and Bruna theoretically show that local minima of a neural network with one hidden layer and ReLU activations can be connected with a curve along which the loss is upper-bounded by a constant that depends on the number of parameters of the network and the “smoothness of the data”. Their theoretical results do not readily generalize to multilayer networks. Using a dynamic programming approach they empirically construct a polygonal chain for a CNN on MNIST and an RNN on PTB next word prediction. However, in more difficult settings such as AlexNet on CIFAR-10 their approach struggles to achieve even the modest test accuracy of 80%80\%. Moreover, they do not consider ensembling.

By contrast, we propose a much simpler training procedure that can find near-constant accuracy polygonal chains with only one bend between optima, even on a range of modern state-of-the-art architectures. Inspired by properties of the loss function discovered by our procedure, we also propose a new state-of-the-art ensembling method that can be trained in the time required to train a single DNN, with compelling performance on many key benchmarks (e.g., 96.4% accuracy on CIFAR-10).

Xie et al. proposed a related ensembling approach that gathers outputs of neural networks from different epochs at the end of training to stabilize final predictions. More recently, Huang et al. proposed snapshot ensembles, which use a cosine cyclical learning rate to save “snapshots” of the model during training at times when the learning rate achieves its minimum. In our experiments, we compare our geometrically inspired approach to Huang et al. , showing improved performance.

Draxler et al. simultaneously and independently discovered the existence of curves connecting local optima in DNN loss landscapes. To find these curves they used a different approach inspired by the Nudged Elastic Band method from quantum chemistry.

Finding Paths between Modes

We describe a new method to minimize the training error along a path that connects two points in the space of DNN weights. Section 3.1 introduces this general procedure for arbitrary parametric curves, and Section 3.2 describes polygonal chains and Bezier curves as two example parametrizations of such curves. In the supplementary material, we discuss the computational complexity of the proposed approach and how to apply batch normalization at test time to points on these curves. We note that after curve finding experiments in Section 4, we make our key methodological proposal for ensembling in Section 5.

where U(0,1)U(0,1) is the uniform distribution on $.Thedifferencebetween(1)and(2)isthatthelatterisanexpectationoftheloss. The difference between (1) and (2) is that the latter is an expectation of the loss\mathcal{L}(\phi_{\theta}(t))withrespecttoauniformdistributiononwith respect to a uniform distribution ont\in,while(1)isanexpectationwithrespecttoauniformdistributiononthecurve.Thetwolossescoincide,forexample,when, while (1) is an expectation with respect to a uniform distribution on the curve. The two losses coincide, for example, when\phi_{\theta}(\cdot)definesapolygonalchainwithtwolinesegmentsofequallengthandtheparametrizationofeachofthetwosegmentsislinearindefines a polygonal chain with two line segments of equal length and the parametrization of each of the two segments is linear int$.

We repeat these updates until convergence.

2 Example Parametrizations

The simplest parametric curve we consider is the polygonal chain (see Figure 1, right). The trained networks w^1\hat{w}_{1} and w^2\hat{w}_{2} serve as the endpoints of the chain and the bends of the chain are the parameters θ\theta of the curve parametrization. Consider the simplest case of a chain with one bend θ\theta. Then

Bezier curve

A Bezier curve (see Figure 1, middle) provides a convenient parametrization of smooth paths with given endpoints. A quadratic Bezier curve ϕθ(t)\phi_{\theta}(t) with endpoints w^1\hat{w}_{1} and w^2\hat{w}_{2} is given by

These formulas naturally generalize for nn bends θ = {w1,w2,…,wn}\theta~{}=~{}\{w_{1},w_{2},\ldots,w_{n}\} (see supplement).

Curve Finding Experiments

We show that the proposed training procedure in Section 3 does indeed find high accuracy paths connecting different modes, across a range of architectures and datasets. Moreover, we further investigate the properties of these curves, showing that they correspond to meaningfully different representations that can be ensembled for improved accuracy. We use these insights to propose an improved ensembling procedure in Section 5, which we empirically validate in Section 6.

In particular, we test VGG-1616 , a 2828-layer Wide ResNet with widening factor 1010 and a 158158-layer ResNet on CIFAR-10, and VGG-1616, 164164-layer ResNet-bottleneck on CIFAR-100. For CIFAR-10 and CIFAR-100 we use the same standard data augmentation as Huang et al. . We provide additional results, including detailed experiments for fully connected and recurrent networks, in the supplement.

For each model and dataset we train two networks with different random initializations to find two modes. Then we use the proposed algorithm of Section 3 to find a path connecting these two modes in the weight space with a quadratic Bezier curve and a polygonal chain with one bend. We also connect the two modes with a line segment for comparison. In all experiments we optimize the loss (2), as for Bezier curves the gradient of loss (1) is intractable, and for polygonal chains we found loss (2) to be more stable.

The constant-error curves connecting two given networks discovered by the proposed method are not unique. We trained two different polygonal chains with the same endpoints and different random seeds using VGG-16 on CIFAR-10. We then measured the Euclidean distance between the turning points of these curves. For VGG-16 on CIFAR-10 this distance is equal to 29.629.6 and the distance between the endpoints is 5050, showing that the curves are not unique. In this instance, we expect the distance between turning points to be less than the distance between endpoints, since the locations of the turning points were initialized to the same value (the center of the line segment connecting the endpoints).

Although high accuracy connecting curves can often be very simple, such as a polygonal chain with only one bend, we note that line segments directly connecting two modes generally incur high error. For VGG-16 on CIFAR-10 the test error goes up to 90%90\% in the center of the segment. For ResNet-158 and Wide ResNet-28-10 the worst errors along direct line segments are still high, but relatively less, at 80%80\% and 66%66\%, respectively. This finding suggests that the loss surfaces of state-of-the-art residual networks are indeed more regular than those of classical models like VGG, in accordance with the observations in Li et al. .

In this paper we focus on connecting pairs of networks trained using the same hyper-parameters, but from different random initializations. Building upon our work, Gotmare et al. have recently shown that our mode connectivity approach applies to pairs of networks trained with different batch sizes, optimizers, data augmentation strategies, weight decays and learning rate schemes.

To motivate the ensembling procedure proposed in the next section, we now examine how far we need to move along a connecting curve to find a point that produces substantially different, but still useful, predictions. Let w^1\hat{w}_{1} and w^2\hat{w}_{2} be two distinct sets of weights corresponding to optima obtained by independently training a DNN two times. We have shown that there exists a path connecting w^1\hat{w}_{1} and w^2\hat{w}_{2} with high test accuracy. Let ϕθ(t)\phi_{\theta}(t), t∈t\in parametrize this path with ϕθ(0)=w^1\phi_{\theta}(0)=\hat{w}_{1}, ϕθ(1)=w^2\phi_{\theta}(1)=\hat{w}_{2}. We investigate the performance of an ensemble of two networks: the endpoint ϕθ(0)\phi_{\theta}(0) of the curve and a point ϕθ(t)\phi_{\theta}(t) on the curve corresponding to t∈t\in. Figure 2 (right) shows the test error of this ensemble as a function of tt, for a ResNet-164 on CIFAR-100. The test error starts decreasing at t≈0.1t\approx 0.1 and for t≥0.4t\geq 0.4 the error of an ensemble is already as low as the error of an ensemble of the two independently trained networks used as the endpoints of the curve. Thus even by moving away from the endpoint by a relatively small distance along the curve we can find a network that produces meaningfully different predictions from the network at the endpoint. This result also demonstrates that these curves do not exist only due to degenerate parametrizations of the network (such as rescaling on either side of a ReLU); instead, points along the curve correspond to meaningfully different representations of the data that can be ensembled for improved performance. In the supplementary material we show how to create trivially connecting curves that do not have this property.

Fast Geometric Ensembling

In this section, we introduce a practical ensembling procedure, Fast Geometric Ensembling (FGE), motivated by our observations about mode connectivity.

In the previous section, we considered ensembling along mode connecting curves. Suppose now we instead only have one set of weights w^\hat{w} corresponding to a mode of the loss. We cannot explicitly construct a path ϕθ(⋅)\phi_{\theta}(\cdot) as before, but we know that multiple paths passing through w^\hat{w} exist, and it is thus possible to move away from w^\hat{w} in the weight space without increasing the loss. Further, we know that we can find diverse networks providing meaningfully different predictions by making relatively small steps in the weight space (see Figure 2, right).

Inspired by these observations, we propose the Fast Geometric Ensembling (FGE) method that aims to find diverse networks with relatively small steps in the weight space, without leaving a region that corresponds to low test error.

While inspired by mode connectivity, FGE does not rely on explicitly finding a connecting curve, and thus does not require pre-trained endpoints, and so can be trained in the time required to train a single network.

Let us describe Fast Geometric Ensembling. First, we initialize a copy of the network with weights ww set equal to the weights of the trained network w^\hat{w}. Now, to force ww to move away from w^\hat{w} without substantially decreasing the prediction accuracy we adopt a cyclical learning rate schedule α(⋅)\alpha(\cdot) (see Figure 3, left), with the learning rate at iteration i=1,2,…i=1,2,\ldots defined as

Figure 3 (left) illustrates the adopted learning rate schedule. During the periods when the learning rate is large (close to α1\alpha_{1}), ww is exploring the weight space doing larger steps but sacrificing the test error. When the learning rate is small (close to α2\alpha_{2}), ww is in the exploitation phase in which the steps become smaller and the test error goes down. The cycle length is usually about 22 to 44 epochs, so that the method efficiently balances exploration and exploitation with relatively-small steps in the weight space that are still sufficient to gather diverse and meaningful networks for the ensemble.

To find a good initialization w^\hat{w} for the proposed procedure, we first train the network with the standard learning rate schedule (the schedule used to train single DNN models) for about 80%80\% of the time required to train a single model. After this pre-training is finished we initialize FGE with w^\hat{w} and run the proposed fast ensembling algorithm for the remaining computational budget. In order to get more diverse samples, one can run the algorithm described above several times for a smaller number of iterations initializing from different checkpoints saved during training of w^\hat{w}, and then ensemble all of the models gathered across these runs.

Cyclical learning rates have also recently been considered in Smith and Topin and Huang et al. . Our proposed method is perhaps most closely related to Snapshot Ensembles , but has several distinctive features, inspired by our geometric insights. In particular, Snapshot Ensembles adopt cyclical learning rates with cycle length on the scale of 2020 to 4040 epochs from the beginning of the training as they are trying to do large steps in the weight space. However, according to our analysis of the curves it is sufficient to do relatively small steps in the weight space to get diverse networks, so we only employ cyclical learning rates with a small cycle length on the scale of 22 to 44 epochs in the last stage of the training. As illustrated in Figure 3 (left), the step sizes made by FGE between saving two models (that is the euclidean distance between sets of weights of corresponding models in the weight space) are on the scale of 77 for Preactivation-ResNet-164 on CIFAR-100. For Snapshot Ensembles for the same model the distance between two snapshots is on the scale of 4040. We also use a piecewise linear cyclical learning rate schedule following Smith and Topin as opposed to the cosine schedule in Snapshot Ensembles.

Fast Geometric Ensembling Experiments

In this section we compare the proposed Fast Geometric Ensembling (FGE) technique against ensembles of independently trained networks (Ind), and SnapShot Ensembles (SSE) , a recent state-of-the-art fast ensembling approach.

For the ensembling experiments we use a 164164-layer Preactivation-ResNet in addition to the VGG-16 and Wide ResNet-28-10 models. Links for implementations to these models can be found in the supplement.

We compare the accuracy of each method as a function of computational budget. For each network architecture and dataset we denote the number of epochs required to train a single model as BB. For a kBkB budget, we run each of Ind, FGE and SSE kk times from random initializations and ensemble the models gathered from the kk runs. In our experiments we set B=200B=200 for VGG-16 and Wide ResNet-28-10 (WRN-28-10) models, and B=150B=150 for ResNet-164, since 150150 epochs is typically sufficient to train this model. We note the runtime per epoch for FGE, SSE, and Ind is the same, and so the total computation associated with kBkB budgets is the same for all ensembling approaches.

For Ind, we use an initial learning rate of 0.1 for ResNet and Wide ResNet, and 0.05 for VGG. For FGE, with VGG we use cycle length c=2c=2 epochs, and a total of 2222 models in the final ensemble. With ResNet and Wide ResNet we use c=4c=4 epochs, and the total number of models in the final ensemble is 1212 for Wide ResNets and 66 for ResNets. For VGG we set the learning rates to α1=10−2\alpha_{1}=10^{-2}, α2=5⋅10−4\alpha_{2}=5\cdot 10^{-4}; for ResNet and Wide ResNet models we set α1=5⋅10−2\alpha_{1}=5\cdot 10^{-2}, α2=5⋅10−4\alpha_{2}=5\cdot 10^{-4}. . For SSE, we followed Huang et al. and varied the initial learning rate α0\alpha_{0} and number of snapshots per run MM. We report the best results we achieved, which corresponded to α0=0.1,M=4\alpha_{0}=0.1,M=4 for ResNet, α0=0.1,M=5\alpha_{0}=0.1,M=5 for Wide ResNet, and α0=0.05,M=5\alpha_{0}=0.05,M=5 for VGG. The total number of models in the FGE ensemble is constrained by network choice and computational budget. Further experimental details are in the supplement.

Table 1 summarizes the results of the experiments. In all conducted experiments FGE outperforms SSE, particularly as we increase the computational budget. The performance improvement against Ind is most noticeable for CIFAR-100. With a large number of classes, any two models are less likely to make the same predictions. Moreover, there will be greater uncertainty over which representation one should use on CIFAR-100, since the number of classes is increased tenfold from CIFAR-10, but the number of training examples is held constant. Thus smart ensembling strategies will be especially important on this dataset. Indeed in all experiments on CIFAR-100, FGE outperformed all other methods. On CIFAR-10, FGE consistently improved upon SSE for all budgets and architectures. FGE also improved against Ind for all training budgets with VGG, but is more similar in performance to Ind on CIFAR-10 when using ResNets.

Figure 3 (right) illustrates the results for Preactivation-ResNet-164 on CIFAR-100 for one and two training budgets. The training budget BB is 150150 epochs. Snapshot Ensembles use a cyclical learning rate from the beginning of the training and they gather the models for the ensemble throughout training. To find a good initialization we run standard independent training for the first 125125 epochs before applying FGE. In this case, the whole ensemble is gathered over the following 2222 epochs (126126-147147) to fit in the budget of each of the two runs. During these 2222 epochs FGE is able to gather diverse enough networks to outperform Snapshot Ensembles both for 1B1B and 2B2B budgets.

Diversity of predictions of the individual networks is crucial for the ensembling performance [e.g., 19]. We note that the diversity of the networks averaged by FGE is lower than that of completely independently trained networks. Specifically, two independently trained ResNet-164 on CIFAR-100 make different predictions on 19.97%19.97\% of test objects, while two networks from the same FGE run make different predictions on 14.57%14.57\% of test objects. Further, performance of individual networks averaged by FGE is slightly lower than that of fully trained networks (e.g. 78.0%78.0\% against 78.5%78.5\% on CIFAR100 for ResNet-164). However, for a given computational budget FGE can propose many more high-performing networks than independent training, leading to better ensembling performance (see Table 1).

ImageNet ILSVRC-2012 is a large-scale dataset containing 1.21.2 million training images and 5000050000 validation images divided into 10001000 classes.

CIFAR-100 is the primary focus of our ensemble experiments. However, we also include ImageNet results for the proposed FGE procedure, using a ResNet-50 architecture. We used a pretrained model with top-11 test error of 23.8723.87 to initialize the FGE procedure. We then ran FGE for 55 epochs with a cycle length of 22 epochs and with learning rates α1=10−3\alpha_{1}=10^{-3}, α2=10−5\alpha_{2}=10^{-5}. The top-11 test error-rate of the final ensemble was 23.3123.31. Thus, in just 55 epochs we could improve the accuracy of the model by 0.560.56 using FGE. The final ensemble contains 44 models (including the pretrained one). Despite the harder setting of only 55 epochs to construct an ensemble, FGE performs comparably to the best result reported by Huang et al. on ImageNet, 23.3323.33 error, which was also achieved using a ResNet-50.

Discussion and Future Work

We have shown that the optima of deep neural networks are connected by simple pathways, such as a polygonal chain with a single bend, with near constant accuracy. We introduced a training procedure to find these pathways, with a user-specific curve of choice. We were inspired by these insights to propose a practical new ensembling approach, Fast Geometric Ensembling, which achieves state-of-the-art results on CIFAR-10, CIFAR-100, and ImageNet.

There are so many exciting future directions for this research. At a high level we have shown that even though the loss surfaces of deep neural networks are very complex, there is relatively simple structure connecting different optima. Indeed, we can now move towards thinking about valleys of low loss, rather than isolated modes.

These valleys could inspire new directions for approximate Bayesian inference, such as stochastic MCMC approaches which could now jump along these bridges between modes, rather than getting stuck exploring a single mode. One could similarly derive new proposal distributions for variational inference, exploiting the flatness of these pathways. These geometric insights could also be used to accelerate the convergence, stability and accuracy of optimization procedures like SGD, by helping us understand the trajectories along which the optimizer moves, and making it possible to develop procedures which can now search in more structured spaces of high accuracy. One could also use these paths to construct methods which are more robust to adversarial attacks, by using an arbitrary collection of diverse models described by a high accuracy curve, returning the predictions of a different model for each query from an adversary. We can also use this new property to create better visualizations of DNN loss surfaces. Indeed, using the proposed training procedure, we were able to produce new types of visualizations showing the connectivity of modes, which are normally depicted as isolated. We also could continue to build on the new training procedure we proposed here, to find curves with particularly desirable properties, such as diversity of networks. Indeed, we could start to use entirely new loss functions, such as line and surface integrals of cross-entropy across structured regions of weight space.

Timur Garipov was supported by Ministry of Education and Science of the Russian Federation (grant 14.756.31.0001). Timur Garipov and Dmitrii Podoprikhin were supported by Samsung Research, Samsung Electronics. Andrew Gordon Wilson and Pavel Izmailov were supported by Facebook Research and NSF IIS-1563887.

References

Appendix A Supplementary Material

We organize the supplementary material as follows. Section A.1 discusses the computational complexity of the proposed curve finding method. Section A.2 describes how to apply batch normalization at test time to points on curves connecting pairs of local optima. Section A.3 provides formulas for a polygonal chain and Bezier curve with nn bends. Section A.4 provides details and results of experiments on curve finding and contains a table summarizing all path finding experiments. Section A.5 provides additional visualizations of the train loss and test accuracy surfaces. Section A.6 contains details on curve ensembling experiments. Section A.7 describes experiments on relation between mode connectivity and the number of parameters in the networks. Section A.8 discusses a trivial construction of curves connecting two modes, where points on the curve represent reparameterization of the endpoints, unlike the curves in the main text. Section A.9 provides details of experiments on FGE. Finally, Section A.10 describes pathways traversed by FGE.

The forward pass of the proposed method consists of two steps: computing the point ϕθ(t)\phi_{\theta}(t) and then passing a mini-batch of data through the DNN corresponding to this point. Similarly, the backward pass consists of first computing the gradient of the loss with respect to ϕθ(t)\phi_{\theta}(t), and then multiplying the result by the Jacobian ∂ϕθ∂θ\frac{\partial\phi_{\theta}}{\partial\theta}. The second step of the forward pass and the first step of the backward pass are exactly the same as the forward and backward pass in the training of a single DNN model. The additional computational complexity of the procedure compared to single model training comes from the first step of the forward pass and the second step of the backward pass and in general depends on the parametrization ϕθ(⋅)\phi_{\theta}(\cdot) of the curve.

In our experiments we use curve parametrizations of a specific form. The general formula for a curve with one bend is given by

thus the additional computational complexity of the backward pass is also O(∣net∣)\mathcal{O}(|net|), as we only need to multiply the gradient with respect to ϕθ(t)\phi_{\theta}(t) by a scalar. Thus, the total additional computational complexity is O(∣net∣)\mathcal{O}(|net|). In practice we observe that the gap in time-complexity between one epoch of training a single model and one epoch of the proposed method with the same network architecture is usually below 50%50\%.

A.2 Batch Normalization

Batch normalization (Ioffe and Szegedy ) is essential to modern deep learning architectures. Batch normalization re-parametrizes the output of each layer as

where μ(x)\mu(x) and σ(x)\sigma(x) are the mean and standard deviation of the output xx, ϵ>0\epsilon>0 is a constant for numerical stability and γ\gamma and β\beta are free parameters. During training, μ(x)\mu(x) and σ(x)\sigma(x) are computed separately for each mini-batch and at test time statistics aggregated during training are used.

When connecting two DNNs that use batch normalization, along a curve ϕ(t)\phi(t), we compute μ(x)\mu(x) and σ(x)\sigma(x) for any given tt over mini-batches during training, as usual. In order to apply batch-normalization to a network on the curve at the test stage we compute these statistics with one additional pass over the data, as running averages for these networks are not collected during training.

A.3 Formulas for curves with n𝑛n bends

For nn bends θ={w1,w2,…,wn}\theta=\{w_{1},w_{2},\ldots,w_{n}\}, the parametrization of a polygonal chain connecting points w0,wn+1w_{0},w_{n+1} is given by

for in+1≤t≤i+1n+1\frac{i}{n+1}\leq t\leq\frac{i+1}{n+1} and 0≤i≤n0\leq i\leq n.

For nn bends θ={w1,w2,…,wn}\theta=\{w_{1},w_{2},\ldots,w_{n}\}, the parametrization of a Bezier curve connecting points w0w_{0} and wn+1w_{n+1} is given by

A.4 Curve Finding Experiments

All experiments on curve finding were conducted with TensorFlow (Abadi et al. ) and as baseline models we used the following implementations:

ResNet-bottleneck-164164 and Wide ResNet-28-10 (https://github.com/tensorflow/models/tree/master/research/resnet);

ResNet-158 (https://github.com/tensorflow/models/tree/master/official/resnet);

A reimplementation of VGG-16 without batch-normalization from (https://github.com/pytorch/vision/blob/master/torchvision/models/vgg.py);

Table 2 summarizes the results of the curve finding experiments with all datasets and architectures. For each of the models we report the properties of loss and the error on the train and test datasets. For each of these metrics we report 3 values: “Max” is the maximum values of the metric along the curve, “Int” is a numerical approximation of the integral {\int{\mbox{<metricmetric>}(\phi_{\theta})}d\phi_{\theta}}/{\int d\phi_{\theta}}, where <<metric>> represents the train loss or the error on the train or test dataset and “Min” is the minimum value of the error on the curve. “Int” represents a mean over a uniform distribution on the curve, and for the train loss it coincides with the loss (11) in the paper. We use an equally-spaced grid with 121121 points on $$ to estimate the values of “Min”, “Max”, “Int”. For “Int” we use the trapezoidal rule to estimate the integral. For each dataset and architecture we report the performance of single models used as the endpoints of the curve as “Single”, the performance of a line segment connecting the two single networks as “Segment”, the performance of a quadratic Bezier curve as “Bezier” and the performance of a polygonal chain with one bend as “Polychain”. Finally, for each curve we report the ratio of its length to the length of a line segment connecting the two modes.

We also examined the quantity “Mean” defined as ∫<\mboxmetric>(ϕθ(t))dt\int{<\mbox{metric}>(\phi_{\theta}(t))}dt, which coincides with the loss (22) from the paper, but in all our experiments it is nearly equal to “Int”.

Besides convolutional and fully-connected architectures we also apply our approach to RNN architecture on next word prediction task, PTB dataset (Marcus et al. ). As a base model we used the implementation available at https://www.tensorflow.org/tutorials/recurrent. As the main loss we consider perplexity. The results are presented in Table 3.

A.5 Train loss and test accuracy surfaces

In this section we provide additional visualizations. Fig. 4 and Fig. 5 show visualizations of the train loss and test accuracy for ResNet-164164 on CIFAR-100 and VGG-1616 on CIFAR-10.

A.6 Curve Ensembling

Here we explore ensembles constructed from points sampled from these high accuracy curves. In particular, we train a polygonal chain with one bend connecting two independently trained ResNet-164 networks on CIFAR-100 and construct an ensemble of networks corresponding to 5050 points placed on an equally-spaced grid on the curve. The resulting ensemble had 21.03%21.03\% error-rate on the test dataset. The error-rate of the ensemble constructed from the endpoints of the curve was 22.0%22.0\%. An ensemble of three independently trained networks has an error rate of 21.01%21.01\%. Thus, the ensemble of the networks on the curve outperformed an ensemble of its endpoints implying that the curves found by the proposed method are actually passing through diverse networks that produce predictions different from those produced by the endpoints of the curve. Moreover, the ensemble based on the polygonal chain has the same number of parameters as three independent networks, and comparable performance.

Furthermore, we can improve the ensemble on the chain without adding additional parameters or computational expense, by accounting for the pattern of increased training and test loss towards the centres of the linear paths shown in Figure 6. While the training and test accuracy are relatively constant, the pattern of loss, shared across train and test sets, indicates overconfidence away from the three points defining the curve: in this region, networks tend to output probabilities closer to 11, sometimes with the wrong answers. This overconfidence decreases the performance of ensembles constructed from the networks sampled on the curves. In order to correct for this overconfidence and improve the ensembling performance we use temperature scaling , which is inversely proportional to the loss. Figure 6, bottom right, illustrates the test loss of ResNet-164 on CIFAR-100 before and after temperature scaling. After rescaling the predictions of the networks, the test loss along the curve decreases and flattens. Further, the test error-rate of the ensemble constructed from the points on the curve went down from 21.03%21.03\% to 20.7%20.7\% after applying the temperature scaling, outperforming 33 independently trained networks.

However, directly ensembling on the curves requires manual intervention for temperature scaling, and an additional pass over the training data for each of the networks (5050 in this case) at test time to perform batch normalization as described in section A.2. Moreover, we also need to train at least two networks for the endpoints of the curve.

A.7 The Effects of Increasing Parametrization

One possible factor that influences the connectedness of a local minima set is the overparameterization of neural networks. In this section, we investigate the relation between the observed connectedness of the local optima and the number of parameters (weights) in the neural network. We start with a network that has three convolutional layers followed by three fully-connected layers, where each layer has 1000K1000K neurons. We vary K∈{0.3,0.5,0.8,1}K\in\{0.3,0.5,0.8,1\}, and for each value of KK we train two networks that we connect with a Bezier curve using the proposed procedure.

For each value of KK, Figure 7 shows the worst training loss along the curve, maximum of losses of the endpoints, and the ratio of the length of the curve and the line segment connecting the two modes. Increasing the number of parameters we are able to reduce the difference between the worst value of the loss along the curve and the loss of single models used as the endpoints. The ratio of the length of the found curve and the length of the line segment connecting the two modes also decreases monotonically with KK. This result is intuitive, since a greater parametrization allows for more flexibility in how we can navigate the loss surfaces.

A.8 Trivial connecting curves

For convolutional networks with ReLU activations and without batch normalization we can construct a path connecting two points in weight space such that the accuracy of each point on the curve (excluding the origin of the weight space) is at least as good as the minimum of the accuracies of the endpoints. Unlike the paths found by our procedure, these paths are trivial and merely exploit redundancies in the parametrization. Also, the training loss goes up substantially along these curves. Below we give a construction of such paths.

Let w^1\hat{w}_{1} and w^2\hat{w}_{2} be two sets of weights. This path of interest consists of two parts. The first part connects the point w^1\hat{w}_{1} with and the second one connects the point w^2\hat{w}_{2} with . We describe only the first part ϕ(t)\phi(t) of the path, such that ϕ(0)=0,ϕ(1)=w^1\phi(0)=0,\phi(1)=\hat{w}_{1}, as the second part is completely analogous. Let the weights of the network w^1\hat{w}_{1} be {Wi,bi}1≤i≤n\{W_{i},b_{i}\}_{1\leq i\leq n} where Wi,biW_{i},b_{i} are the weights and biases of the ii-th layer, and nn is the total number of layers. Throughout the derivation we consider the inputs of the network fixed. The output of the ii-th layer oi=Wi\mboxReLU(oi−1)+bio_{i}=W_{i}\mbox{ReLU}(o_{i-1})+b_{i}, 1≤i≤n1\leq i\leq n, where i=0i=0 corresponds to the first layer and i=ni=n corresponds to logits (the outputs of the last layer). We construct ϕ(t)={Wi(t),bi(t)}1≤i≤n\phi(t)=\{W_{i}(t),b_{i}(t)\}_{1\leq i\leq n} in the following way. We set Wi(t)=WitW_{i}(t)=W_{i}t and bi(t)=biti.b_{i}(t)=b_{i}t^{i}. It is easy to see that logits of the network with weights ϕ(t)\phi(t) are equal to on(t)=tnono_{n}(t)=t^{n}o_{n} for all t>0t>0. Note that the predicted labels corresponding to the logits on(t)o_{n}(t) and ono_{n} are the same, so the accuracy of all networks corresponding to t>0t>0 is the same.

A.9 Fast geometric ensembling experiments

Alg. 1 provides an outline of the algorithm. As baseline models we used the following implementations:

VGG-16 (https://github.com/pytorch/vision/blob/master/torchvision/models/vgg.py);

Preactivation-ResNet-164 (https://github.com/bearpaw/pytorch-classification/blob/master/models/cifar/preresnet.py);

ResNet-50 ImageNet (https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py);

Wide ResNet-28-10 (https://github.com/meliketoy/wide-resnet.pytorch/blob/master/networks/wide_resnet.py);

For the FGE (Fast Geometric Ensembling) strategy on ResNet we run the FGE routine summarized in Alg. 11 after epoch 125125 of the usual (same as Ind) training for 2222 epochs. The total training time is thus 125+22=147125+22=147 epochs. For VGG and Wide ResNet models we run the pre-training procedure for 156156 epochs to initialize FGE. Then we run FGE for 2222 epochs starting from checkpoints corresponding to epochs 120120 and 156156 and ensemble all the gathered models. The total training time is thus 156+22+22=200156+22+22=200 epochs. For VGG we use cycle length c=2c=2 epochs, which means that the total number of models in the final ensemble is 2222. For ResNet and Wide ResNet we use c=4c=4 epochs, and the total number of models in the final ensemble is 1212 for Wide ResNets and 66 for ResNets.

A.10 Polygonal chain connecting FGE proposals

In order to better understand the trajectories followed by FGE we construct a polygonal chain connecting the points that FGE ensembles. Suppose we run FGE for nn learning rate cycles obtaining nn points w1,w2,…,wnw_{1},w_{2},\ldots,w_{n} in the weight space that correspond to the lowest values of the learning rate. We then consider the polygonal chain consisting of the line segments connecting wiw_{i} to wi+1w_{i+1} for i=1,…,n−1i=1,\ldots,n-1. We plot test accuracy and train error along this polygonal chain in Figure 8. We observe that along this curve both train loss and test error remain low, agreeing with our intuition that FGE follows the paths of low loss and error. Surprisingly, we find that the points on the line segments connecting the weights wi,wi+1w_{i},w_{i+1} have lower train loss and test error than wiw_{i} and wi+1w_{i+1}. See Izmailov et al. for a detailed discussion of this phenomenon.