Sharpness-Aware Training for Free
Abstract
Modern deep neural networks (DNNs) have achieved state-of-the-art performances but are typically over-parameterized.
The over-parameterization may result in undesirably large generalization error in the absence of other customized training strategies.
Recently, a line of research under the name of Sharpness-Aware Minimization (SAM) has shown that minimizing a sharpness measure, which reflects the geometry of the loss landscape, can significantly reduce the generalization error.
However, SAM-like methods incur a two-fold computational overhead of the given base optimizer (e.g. SGD) for approximating the sharpness measure.
In this paper, we propose Sharpness-Aware Training for Free , or SAF , which mitigates the sharp landscape at almost zero additional computational cost over the base optimizer.
Intuitively, SAF achieves this by avoiding sudden drops in the loss in the sharp local minima throughout the trajectory of the updates of the weights.
Specifically, we suggest a novel trajectory loss, based on the KL-divergence between the outputs of DNNs with the current weights and past weights, as a replacement of the SAM’s sharpness measure.
This loss captures the rate of change of the training loss along the model’s update trajectory.
By minimizing it, SAF ensures the convergence to a flat minimum with improved generalization capabilities.
Extensive empirical results show that SAF minimizes the sharpness in the same way that SAM does, yielding better results on the ImageNet dataset with essentially the same computational cost as the base optimizer.
Our codes are available at https:/ /github.com/ AngusDujw /SAF.
Introduction
Despite achieving remarkable performances in many applications, powerful neural networks [2, 5, 21, 26, 26, 27, 34, 35] are typically over-parameterized.
Such over-parameterized deep neural networks require advanced training strategies to ensure that their generalization errors are appropriately small [2, 32] and the adverse effects of the overfitting are alleviated.
Understanding how deep neural networks generalize is perhaps the most fundamental and yet perplexing topic in deep learning.
Numerous studies expend significant amounts of efforts to understand the generalization capabilities of deep neural networks and mitigate this problem from a variety of perspectives, such as the information perspective [18], the model compression perspective [1, 9], and the Bayesian perspective [22, 24], etc.
The loss surface geometry perspective, in particular, has attracted a lot of attention from researchers recently [4, 12–14, 28].
These studies connect the generalization gap and the sharpness of the minimum’s loss landscape, which can be characterized by the largest eigenvalue of the Hessian matrix ∇ 2 θ f θ [14] where f θ represents the input-output map of the neural network.
In other words, a (local) minimum that is located in a flatter region tends to generalize better than one that is located in a sharper one [4, 13].
The recent work [8] proposes an effective and generic training algorithm, named Sharpness-Aware Minimization (SAM), to encourage the training process to converge to a flat 36th Neural
Systems ( minimum. SAM explicitly penalizes a sharpness measure to obtain flat minima, which has achieved state-of-the-art results in several learning tasks [2, 36].
[Figure]
Unfortunately, SAM’s computational cost is twice that compared to the given base optimizer, which is typically stochastic gradient descent (SGD).
This prohibits SAM from being deployed extensively in highly over-parameterized networks.
Half of SAM’s computational overhead is used to approximate the sharpness measure in its first update step.
The other half is used by SAM to minimize the sharpness measure together with the vanilla loss in the second update step.
As shown in Figure 1, SAM significantly reduces the generalization error at the expense of double computational overhead.
Liu et al.
[20] and Du et al.
[6] recently addressed the computation issue of SAM and proposed LookSAM [20] and Efficient SAM (ESAM)
[6], respectively.
LookSAM only minimizes the sharpness measure once in the first of every five iterations.
For the other four iterations,
LookSAM reuses the gradients that minimizes the sharpness measure, which is obtained by decomposing the SAM’s updated gradients in the first iteration into two orthogonal directions.
As a result, LookSAM saves 40% computations compared to SAM but unfortunately suffers from performance degradation.
On the other hand, ESAM proposes two strategies to save the computational overhead in SAM’s two updating steps.
The first strategy approximates the sharpness by using fewer weights for computing; the other approximates the updated gradients by only using a subset containing the instances that contribute the most to the sharpness.
ESAM is reported to save up to 30% computations without degrading the performance.
However, ESAM’s efficiency degrades in large-scale datasets and architectures (from 30% on CIFAR10/100 to 22% on ImageNet).
LookSAM and ESAM both follow SAM’s path to minimize SAM’s sharpness measure, which limits the potential for further improvement of their efficiencies.
In this paper, we aim to perform sharpness-aware training with zero additional computations and yet still retain superior generalization performance .
Specifically, we introduce a novel trajectory loss to replace SAM’s sharpness measure loss.
This trajectory loss measures the KL-divergence between the outputs of neural networks with the current weights and those with the past weights.
We propose the Sharpness-Aware training for Free (SAF) algorithm to penalize the trajectory loss for sharpness-aware training.
More importantly, SAF requires almost zero extra computations (SAF 0.7% v.s. SAM 100%).
SAF memorizes the outputs of DNNs in the process of training as the targets of the trajectory loss.
By minimizing it, SAF avoids the quick converging to a local sharp minimum.
SAF has the potential to result in out-of-memory issue on extremely large scale datasets, such as
ImageNet-21K [15] and JFT-300M [25].
We also introduce a memory-efficient variant of SAF, which is Memory-Efficient Sharpness-Aware Training (MESA).
MESA adopts a DNN whose weights are the exponential moving averages (EMA) of the trained DNN to output the targets of the trajectory loss.
As a result, MESA resolves the out-of-memory issue on extremely large scale datasets, at the cost of 15% additional computations (v.s. SAM 100%).
As shown in Figure 2, SAF and MESA both encourage the training to converge to flat minima similarly as SAM.
Besides visualizing the loss landscape, we conduct experiments on the CIFAR-10/100 [16] and the ImageNet [3] datasets to verify the effectiveness of SAF.
The experimental results indicate that our proposed SAF and
MESA outperform SAM and its variants with almost twice the training speed; this is illustrated on the ImageNet-1k dataset in Figure 1.
In a nutshell, we summarize our contributions as follows
• We propose a novel trajectory loss to measure the sharpness to be used for sharpness-aware training.
Requiring almost zero extra computational overhead, this trajectory loss is a better loss to quantify the sharpness compared to SAM’s loss.
• We address the efficiency issue of current sharpness-aware training, which generally incurs twice the computational overhead compared to regular training.
Based on our proposed trajectory loss, we propose the novel SAF algorithm for improved generalization ability in this paper.
SAF is demonstrated to outperform SAM on the ImageNet dataset, with the same computational cost as the base optimizer.
• We also propose the MESA algorithm as a memory-efficient variant of SAF.
MESA reduces the extra memory-usage of SAF at the cost of 15% additional computations, which allows SAF/MESA to be deployed efficiently (both in terms of memory and computation) on extremely large-scale datasets (e.g. ImageNet-21K [15]).
Preliminaries
Throughout the paper, we use f θ to denote a neural network with weight parameters θ .
We are given a training dataset S that contains i.i.d.
samples drawn from a natural distribution D .
The training of the network is typically a non-convex optimization problem which aims to search for an optimal weight vector ˆ θ that satisfies
[Equation]
where ℓ can be an arbitrary loss function, and we use x i to denote the pair (inputs, targets) of the i -th element in the training set.
In this paper, we take ℓ to be the cross entropy loss; We use ∥·∥ represents ℓ 2 norm; we assume that L S ( f θ ) is continuous and differentiable, and its first-order derivation is bounded .
In each training iteration, optimizers randomly sample a mini-batch B t ⊂ S with a fixed batch size.
Sharpness-Aware Minimization
The conventional optimization and training focuses on minimizing the empirical loss of a single weight vector ˆ θ over the training set S as stated in Equation 1.
This training paradigm is known as empirical risk minimization , and tends to overfit to the training set and converges to sharp minima.
Sharpness-Aware Minimization (SAM) [8] aims to encourage the training to converge to a flatter region in which the training losses in the neighborhood around the minimizer ˆ θ are lower.
To achieve this, SAM proposes a training scheme that solves the following min-max optimization problem:
[Equation]
where ρ is a predefined constant that constrains the radius of the neighborhood; ϵ is the weight perturbation vector that maximizes the training loss within the ρ -constrained neighborhood.
The objective loss function of SAM can be rewritten as the sum of the vanilla loss and the loss associated to the sharpness measure, which is the maximized change of the training loss within the ρ -constrained neighborhood, i.e.,
[Equation]
where R S ( f θ ) = max ϵ : ∥ ϵ ∥ 2 ≤ ρ L S ( f θ + ϵ ) − L S ( f θ ) .
[Equation]
The sharpness measure is approximated as R S ( f θ ) =
L S ( f θ +ˆ ϵ ) − L S ( f θ ) , where ˆ ϵ is the solution to an approximated version of the maximization problem where the objective is the first-order Taylor series approximation of L S ( f θ + ϵ ) around θ , i.e.,
[Equation]
Intuitively, SAM seeks flat minima with low variation in their training losses when the optimal weights are slightly perturbed.
Methodology
The fact that SAM’s computational cost is twice that compared to the base optimizer is its main limitation.
The additional computational overhead is used to compute the sharpness term R S ( f θ ) in Equation 3.
We propose a new trajectory loss as a replacement of SAM’s sharpness loss R S ( f θ ) with essentially zero extra computational overhead over the base optimizer.
Next, we introduce the
Sharpness-Aware Training for Free (SAF) algorithm whose pseudocode can be found in Algorithm 1.
We first start with recalling SAM’s sharpness measure loss.
Then we explain the intuition for the trajectory loss as a substitute for SAM’s sharpness measure loss in Section 3.1.
Next, we present the complete algorithm of SAF in Section 3.2 and a memory-efficient variant of it in Section 3.3.
Update
Compute
Defined
[Equation] =
[Equation]
Update the weights: θ ← θ − η ∇ θ L
Output: A flat minimum solution ˜ θ .
3.1 General Idea: Leverage the trajectory of weights to estimate the sharpness
We first rewrite the sharpness measure R B ( f θ ) of SAM based on its first-order Taylor expansion.
Given a vector ˆ ϵ (Equation 4) whose norm is small, we have
[Equation]
[Equation] We remark that minimizing the sharpness loss R B ( f θ ) is equivalent to minimizing the ℓ 2 -norm of the gradient ∇ θ L B ( f θ ) , which is the same gradient used to minimize the vanilla loss L B ( f θ ) .
The learning rate η in the standard training (using SGD) is typically smaller than ρ as suggested by
SAM [8].
Hence, if the mini-batch B is the same for the two consecutive iterations, the change of the training loss after the weights have been updated can be approximated as follow,
[Equation]
[Equation]
We also remark that the change of the training loss after the weights have been updated is proportional to R B ( f θ ) 2 .
Hence, minimizing the loss difference is equal to minimizing the sharpness loss of SAM in this case.
[Figure]
This inspires us to leverage the update of the weights in the standard training to approximate SAM’s sharpness measure.
Regrettably though, the samples in the mini-batches
B t and B t +1 in two consecutive iterations are different with high probability, which does not allow the sharpness to be computed as in Equation 6.
This is precisely the reason why SAM uses an additional step to compute ˆ ϵ for approximating the sharpness.
To avoid these additional computations completely, we introduce a novel trajectory loss that makes use of the trajectory of the weights learned in the standard training procedure to measure sharpness.
We denote the past trajectory of the weights as the iterations progress as Θ = { θ 2 , θ 3 , . . .
, θ t − 1 } .
Hence, θ t represents the weights in the t -th iteration, which is also the current model update step.
We use SGD as the base optimizer to illustrate our ideas.
Recall that standard SGD updates the weights as θ t +
=
θ t − η ∇ θ t L B t ( f θ t ) .
We aim to derive an equivalent term of the sharpness R B t ( f θ t ) that can be computed without additional computations . The quantity R B t ( f θ t ) as defined in Equation 5 is always non-negative, and thus we have
[Equation]
where θ i ∼ Unif(Θ) means that θ i is uniformly distributed in the set Θ , γ t is defined as η t ρ 2 cos(Φ t ) , where Φ t is the angle between the gradients that are computed using the mini-batches B i and B t , respectively. Note that for i ̸
= t , γ i R B t ( f θ i ) R B i ( f θ i )] is a constant with respect to the variable θ t . Therefore, when we traverse all the terms that satisfy i ̸ = t , we obtain Equation 7.
Hence, the sharpness can therefore be alternatively estimated as follows:
[Equation]
Further details of the above derivation can be found in Appendix A.1.
We remark that minimizing the loss difference L B t ( f θ 1 ) − L B t ( f θ t ) is equivalent to minimizing the SAM’s sharpness measure R B t ( f θ t ) .
Accordingly, requiring no additional computational overhead, the training loss difference is a good proxy to SAM’s loss R B t ( f θ t ) to quantify and penalize the sharpness.
3.2 Sharpness-Aware Training for Free (SAF)
We elaborate our proposed training algorithm SAF in this subsection.
To estimate the sharpness precisely, SAF only takes the update trajectory in the past ˜ E epochs into consideration.
When simultaneously minimizing the vanilla loss and the training loss difference (as in Equation 8), the second term − L B T ( f θ T ) will unfortunately cancel out the vanilla loss.
Therefore, we replace the cross entropy loss with the Kullback–Leibler (KL) divergence loss to decouple the vanilla loss.
We also soften the targets of the KL divergence loss using a temperature τ .
Accordingly, the trajectory loss at e -th epoch is defined as follow
[Equation]
where Y ( e − ˜ E ) =
(cid:8) ˆ y ( e − ˜ E ) i =
f ( e − ˜ E )
θ ( x i ) :
x i ∈ B (cid:9) .
We remark that ˆ y ( e − ˜ E )
i is the network output of the instance x i in ˜ E epochs ago, as illustrated in Line 4 of Algorithm 1.
The outputs of each instance x i will be recorded, and no additional computations are required during this procedure.
The trajectory loss will be deployed after a predefined epoch E start
(Line 10 of Algorithm 1), because the outputs of the DNN are neither stable nor reliable at the first few epochs.
Intuitively, the trajectory loss slows down the rate of change of the training loss to avoid convergence to sharp local minima. This is illustrated in Figure 3.
3.3 Memory-Efficient Sharpness-Aware Training (MESA)
The memory usage for recording the outputs is negligible for standard datasets such as CIFAR [16] (57 MB).
However, SAF’s memory usage is proportional to the size of the training datasets, which may result in an out-of-memory issue on extremely large-scale datasets such as ImageNet-21k [15] and JFT-300M [25].
Another limitation of SAF is that the coefficient γ t will decay at the same rate as the learning rate η t since γ t ∝ η t as shown in Equation 8.
Hence, the sharpness at the current weights are quantified by smaller coefficients γ t .
For a SAF-like algorithm to be applicable on extremely large-scale datasets and to emphasize the sharpness of the most current or recent weights, we introduce Memory-Efficient Sharpness-Aware Training (MESA), which adopts an exponential moving average (EMA) weighting strategy on the weights to construct the trajectory loss.
The EMA weight v t at the t -th iteration is updated as follows
[Equation]
where β ∈ (0 . 9 , 1) is the decay coefficient of EMA.
Given that v 1 = θ 1 , and θ t +1 =
θ t − η ∇ θ t L B t ( f θ t ) , the EMA weight in the t -th iteration, can be expressed as
[Equation]
More details of this derivation can be found in Appendix A.2.
Therefore, the trajectory from θ t to v t is collected in the vector W EMA = ( w 2 , w 3 , . . .
w t − 1 ) , where w i = w i − 1 − β t − i η ∇ θ i L B i ( f θ i ) , w 1 = v t , and w t = θ t .
If we regard the outputs of EMA model f v t as the targets of the trajectory loss, and substitute it into Equation 8,
[Equation]
More details can be found in Appendix A.1.
Hence, the EMA coefficients β t − i will place more emphasis on the sharpness of the current and most recent weights since 0 < β < 1 .
The trajectory loss of MESA is
[Equation]
We see that the difference between this and the trajectory loss L tra B ( f θ , Y ( e − ˜ E ) ) discussed in Section 3.2 is that the target ˆ y ( e − ˜ E ) i at the t -iteration has been replaced by f v t ( x i ) for x i ∈ B .
Experiments
We verify the effectiveness of our proposed SAF and MESA algorithms in this section.
We first conduct experiments to demonstrate that our proposed SAF achieves better performance compared to SAM which requires twice the training speed.
SAF is shown to outperform SAM and its variants in large-scale datasets and models.
The main results are summarized into Tables 1 and 3.
Next, we evaluate the sharpness of SAF using the measurement proposed by SAM.
We demonstrate that SAF encourages the training to converge to a flat minimum.
We also visualize the loss landscape of the minima converged by SGD, SAM, SAF, and MESA in Figures 2 and 5, which show that both SAF’s and MESA’s loss landscapes are as flat as SAM.
4.1 Experiment Setup
Datasets We conduct experiments on the following image classification benchmark datasets: CIFAR10, CIFAR-100 [16], and ImageNet [3].
The 1000-class ImageNet dataset contains roughly 1. million training images, which is the popular benchmark for evaluating large-scale training.
Models We employ a variety of widely-used DNN architectures to evaluate the performance and training speed.
We use ResNet-18 [11], Wide ResNet-28-10 [31], and PyramidNet-110 [10] for the training in CIFAR-10/100 datasets.
We use ResNet [11] and Vision Transformer [5] models with various sizes on the ImageNet dataset.
Baselines We take the vanilla (AdamW for ViT, SGD for the other models), SAM [8], ESAM [6],
GSAM [36], and LookSAM [20] as the baselines.
ESAM and LookSAM are SAM’s follow-up works that improve efficiency.
GSAM achieves the best performance among the SAM’s variants.
We reproduce the results of the vanilla and SAM, which matches the reported results in [2, 20, 36].
And we report the cited results of baselines ESAM [6], GSAM [36], and LookSAM [20].
Implementation details We set all the training hyperparameters to be the same for a fair comparison among the baselines and our proposed algorithms.
The details of the training setting are displayed in the Appendix.
We follow the settings of [2, 6, 20, 36] for the ImageNet datasets, which is different from the experimental setting of the original SAM paper [8].
The codes are implemented based on the TIMM framework [29].
The ResNets are trained with a batch size of 4096, 1.4 learning rate, 90 training epochs, and SGD optimizer (momentum=0.9) over 8 Nvidia V-100 GPU cards.
The ViTs are trained with 300 training epochs and AdamW optimizer ( β 1 = 0 .
9 , β 2 = 0 .
We only conduct the basic data augmentation for the training on both CIFAR and ImageNet (Inceptionstyle data augmentation).
The hyperparameters of SAF and MESA are consistent among various DNNs architectures and various datasets.
We set τ = 5 , ˜ E
= 3 , E start = 5 for all the experiments, λ ∈ { 0 . 3 , 0 . 8 } for SAF and MESA , respectively. [Table]
[Table]
4.2 Experimental Results
ImageNet Our proposed SAF and MESA achieve better performance on the ImageNet dataset compared to the other competitors.
We report the best test accuracies and the average training speeds 200 Epochs 0. T r a i n i n g L o ss ) SAM
[Figure]
MESA
[Figure] 200 Epochs 0. S h a r p n e ss ( S A M ) [Figure]
[Figure]
[Figure]
in Table 1.
The experiment results demonstrate that SAF incurs no additional computational overhead to ensure that the training speed is the same as the base optimizer—SGD.
We observe that SAF and
MESA perform better in the large-scale datasets.
SAF trains DNN at a douled speed than SAM (SAF 99.2% vs SAM 50%).
MESA achieves a training speed which is 84% to 85% that of SGD.
Concerning the performance, both SAF and MESA outperform SAM up to (0.9%) on the ImageNet dataset.
More importantly, SAF and MESA achieve a new state-of-the-art results of SAM’s follow-up works on the ImageNet datasets trained with ResNets.
CIFAR10 and CIFAR
We ran all the experiments three times with different random seeds for fair comparisons.
We summarize the results in Table 3, in the same way as we do for the experiments on the ImageNet dataset.
The training speed is consistent with the results on ImageNet.
Similarly,
SAF and MESA outperform SAM on large-scale models—Wide Resnet and PyradmidNets.
4.3 Discussion
Memory Usage We evaluate the additional memory usage of SAF and MESA on the ImageNet dataset with the ResNet-50 model.
We only present the results on the ImageNet in Table 2, because the memory usage of SAF on the CIFAR dataset is negligible (57 Mb).
MESA saves 99 . 3% memory usage compared to SAF, which allows MESA to be deployed on extremely large-scale datasets.
[Table]
Convergence Rate Intuitively, SAF minimizes the trajectory loss to control the rate of training loss change to obtain flat minima.
A critical problem of SAF may be SAF’s influence on the convergence rate.
We empirically show that the change of the sharpness-inducing term in SAF and MESA (compared to SAM) will not affect the convergence rate during training.
Figure 4a illustrates the change of the training loss in each epoch of SGD, SAM, SAF, and MESA.
It shows that SAF and MESA converge at the same rate as SGD and SAM.
Sharpness We empirically demonstrate that the trajectory loss can be a reliable proxy of the sharpness loss proposed by SAM.
We plot the sharpness, which is the measurement of SAM in Equation 6, in each epoch of SAM, SGD, SAF, and MESA during training.
As shown in Figure 4b, SAF and MESA minimize the sharpness as SAM does throughout the entire training procedure.
Both SAF’s and MESA’s sharpness decrease significantly at epoch 5, from which the trajectory loss starts to be minimized.
SAM’s sharpness is lower than SAF’s and MESA’s in the second half of the training.
A plausible reason is that SAM minimizes the sharpness directly.
However, SAF and MESA outperform SAM in terms of the test accuracies, as demonstrated in Table [-1.
-]1.
Visualization of Loss Landscapes
We also demonstrate that minimizing the trajectory loss is an effective way to obtain flat minima.
We visualize the loss landscape of converged minima trained by SGD, SAM, SAF, and MESA in Figures 2 and 5.
We follow the method to do the plotting proposed by [17], which has also been used in [2, 6].
The x - and y -axes represent two random sampled orthogonal Gaussian perturbations.
We sampled 100 × 100 points with random Gaussian perturbations for visualization.
The visualized loss landscape clearly demonstrate that SAF can converge to a region as flat as SAM does. [Table]
Other Related Works
The first work that revealed the relation between the generalization ability and the geometry of the loss landscape (sharpness) can be traced back to [12].
Following that, many studies verified the relation between the flat minima and the generalization error [4, 7, 13, 14, 17, 19, 23] .
Specifically,
Keskar et al.
[14] proposed a sharpness measure and indicated the negative correlation between the sharpness measure and the generalization abilities.
Dinh et al.
[4] further argued that the sharpness measure can be related to the spectrum of the Hessian [Table] whose eigenvalues encode the curvature information of the loss landscape.
Jiang et al.
[13] demonstrated that one of the sharpness-based measures is the most correlated one among 40 complexity measures by a large-scale empirical study.
SAM [8] solved the sharp minima problem by modifying training schemes to approximate and minimize a certain sharpness measure.
The concurrent works [30, 33] propose a model to adversarially perturb trained weights to bias the convergence.
The aforementioned methods lead the way for sharpness-aware training despite the computational overhead being doubled over that of the base optimizer.
Subsequently, LookSAM [20] and Efficient SAM (ESAM)
[6] were proposed to alleviate the computational issue of SAM.
Apart from efficiency issues, Surrogate Gap Guided
Sharpness-Aware Minimization (GSAM)
[36] was proposed to further improve SAM’s performance.
GSAM places more emphasis on the gradients that minimize the sharpness loss to achieve the best generalization performance among all the research that followed SAM.
Conclusion and Future Research
In this work, we introduce a novel trajectory loss as an equivalent measure of sharpness, which requires almost no additional computational overhead and preserves the superior performance of sharpness-aware training [6, 8, 20, 36].
In addition to deriving a novel trajectory loss that penalizes sharp and sudden drops in the objective function, we propose a novel sharpness-aware algorithm SAF, which achieves impressive performances in terms of its accuracies on the benchmark CIFAR and
ImageNet datasets.
More importantly, SAF trains DNNs at the same speed as non-sharpness-aware training (e.g., SGD).
We also propose MESA as a memory-efficient variant of SAF to avail sharpnessaware training on extremely large-scale datasets.
In future research, we will further enhance SAF to automatically sense the current state of training and alter the training dynamics accordingly.
We will also evaluate SAF in more learning tasks (such as natural language processing) and enhance it to become a general-purpose training strategy.
Acknowledgments and Disclosure of Funding
This work is support by Joey Tianyi Zhou’s A*STAR SERC Central Research Fund (Use-inspired
Basic Research) and the Singapore Government’s Research, Innovation and Enterprise 2020 Plan (Advanced Manufacturing and Engineering domain) under Grant A18A1b0045.
Vincent Tan acknowledges funding from a Singapore National Research Foundation (NRF) Fellowship (A-0005077-01-00) and Singapore Ministry of Education (MOE) AcRF
Tier 1 Grants (A-000904201-00 and A-8000189-01-00).
By substituting Equation 5 back into the LHS of Equation 8, we have,
[Equation] When we replace the trajectory from Θ = { θ 2 , θ 3 , . .
. , θ t − 1 } to W EMA = { w 2 , w 3 , . . . , w t − 1 }
[Equation]
where w i = w i − 1 − β t − i η ∇ θ i L B i ( f θ i ) , w 1 = v t
[Equation] and w t = θ t [Equation] and substitute it back into Equation 8, we have
[Equation]
We see that the difference between this and Equation 8 is the additional coefficient β t − i of each term. The coefficient β t − i is monotonic increasing as i increases, since 0 < β < 1 .
Therefore, β t − i will put more emphasis on the more recent weights.
By definition of Exponential Moving Average (EMA), the EMA weights v t in the t -th iterations are as follows
[Equation]
Let g i =
η ∇ θ i L B i ( f θ i ) . We recall that [Equation]
Substituting Equation 15 into Equation 14, we obtain
[Equation]
as desired.
A.3 Visualization of the loss landscape
We also visualize the central loss landscape around the converged minimum of the Wide-28-10 model, as the sharpness of the central landscape around the converged minimum is more predicative of the generalization ability.
The visualized loss landscape clearly demonstrate that both SAF and MESA can converge to a region as flat as SAM does.
A.4 Training Details
We search the training parameters of SGD, SAM, SAF and MESA via grid searches on an isolated validation set of CIFAR datasets. The learning rate is chosen from the set { 0 . 01 , 0 . 05 , 0 . 1 , 0 . 2 } , the weight decay from the set { 5 × 10 − 4 , 1 × 10 − 3 } , and the batch size from the set { 64 , 128 , 256 } .
We choose the hyperparameters that achieves the best test accuracies and report them in Table 4.
We also report the hyperparameters on the ImageNet datasets in Table 5.
The set of hyperparameters { E start , ˜ E, τ } is consistent among the experiments on the CIFAR and
ImageNet datasets.
We set { E start = 5 , ˜ E
= 3 , τ = 5 } for each model on the CIFAR-10/ dataset. For the ImageNet dataset, we set { E start = 10 , ˜ E = 3 , τ = 5 } for the ResNets and { E start = 150 , ˜ E = 3 , τ = 5 } for the ViT.
[Table]
[Table]