Recent progress in optimization research has highlighted the sharpness of the loss landscape as a key factor in narrowing the generalization gap. Motivated by this insight, Sharpness-Aware Minimization (SAM) was proposed as a training strategy that enhances generalization. Despite the promising performance, SAM suffers from its twice computational cost due to its core algorithm requiring an extra gradient computation during the perturbation step. To overcome this limitation, we introduce Exponential Moving Average Sharpness-Aware Minimization (EMASAM), a computationally efficient variant of SAM. EMASAM does not require the loss gradient in the perturbation step. Instead, EMASAM defines the perturbation direction based on the discrepancy between the main model and the EMA shadow model. This perturbation travels away from the stable average position toward the less stable area, acting as a softer yet cheaper alternative to SAM's worst-case scenario perturbation. Moreover, since EMASAM's perturbation does not rely on noisy mini-batch gradients, it mitigates the gradient-induced instability inherent in SAM. Hence, EMASAM eliminates the need for an extra backpropagation while also preserving the generalization ability of the SAM-style training. Several experiments have been performed and confirm the efficiency and robustness of our method.
Figures & tables
Figure 1: Diagram illustrates the algorithm of SGD, EMA, SAM, and EMASAM.
ρ
with normalization
w/o normalization
0.01
81.74 ± 0.24
80.85 ± 0.33
0.02
81.44 ± 0.13
81.03 ± 0.39
0.05
81.46 ± 0.26
80.55 ± 0.17
0.1
81.26 ± 0.47
81.38 ± 0.24
0.2
81.24 ± 0.17
81.15 ± 0.15
0.5
81.65 ± 0.32
80.58 ± 0.58
Table 1: Accuracies ( % ) for hyperparameter tuning of EMASAM on ResNet-50 on CIFAR-100
Method
CIFAR-10
CIFAR-100
Fashion-MNIST
EMNIST
Average
Vanilla (SGD)
94.57 ± 0.07
77.62 ± 0.47
89.81 ± 0.78
88.07 ± 0.24
87.52
SAM [ 11 ]
96.09 ± 0.03
79.80 ± 0.29
92.21 ± 0.14
90.11 ± 0.02
89.55
SS-SAM [ 40 ]
95.64 ± 0.31
79.34 ± 0.85
91.93 ± 0.74
89.75 ± 0.17
89.17
AE-SAM
95.79 ± 0.08
78.71 ± 0.55
92.39 ± 0.19
90.02 ± 0.12
89.23
MSAM [ 1 ]
94.84 ± 0.14
78.18 ± 0.16
92.21 ± 0.21
89.39 ± 0.48
88.65
EMA
96.04 ± 0.11
79.25 ± 0.25
90.98 ± 0.14
88.01 ± 0.15
88.57
Table 2: Accuracies ( % ) of models trained with ResNet-18
Method
CIFAR-10
CIFAR-100
Fashion-MNIST
EMNIST
Average
Vanilla (SGD)
94.56 ± 0.15
77.21 ± 0.09
90.87 ± 1.03
88.44 ± 0.16
87.77
SAM [ 11 ]
96.00 ± 0.13
79.41 ± 0.61
92.33 ± 0.24
89.25 ± 0.60
89.25
SS-SAM [ 40 ]
95.63 ± 0.18
79.91 ± 0.26
92.22 ± 0.00
89.43 ± 0.11
89.30
AE-SAM [ 16 ]
95.45 ± 0.33
78.82 ± 1.32
92.18 ± 0.09
89.02 ± 0.11
88.87
MSAM [ 1 ]
93.16 ± 0.21
78.16 ± 0.73
90.41 ± 0.24
88.41 ± 0.53
87.54
EMA
96.49 ± 0.06
81.50 ± 0.23
90.38 ± 0.10
87.96 ± 0.09
89.08
Table 3: Accuracies ( % ) of models trained with ResNet-50
Method
CIFAR-10
CIFAR-100
Fashion-MNIST
EMNIST
Average
Vanilla (SGD)
95.83 ± 0.11
81.50 ± 0.27
89.54 ± 0.88
86.67 ± 0.38
88.39
SAM [ 11 ]
96.96 ± 0.05
84.05 ± 0.27
91.63 ± 0.26
89.58 ± 0.13
90.55
SS-SAM [ 40 ]
96.75 ± 0.15
83.03 ± 0.09
91.54 ± 0.26
89.74 ± 0.15
90.26
AE-SAM [ 16 ]
96.96 ± 0.08
83.40 ± 0.10
91.89 ± 0.40
89.55 ± 0.13
90.45
MSAM [ 1 ]
95.74 ± 0.02
82.27 ± 0.13
91.63 ± 0.40
87.89 ± 0.32
89.38
EMA
96.70 ± 0.01
81.96 ± 0.02
90.39 ± 0.23
86.10 ± 0.19
88.79
Table 4: Accuracies ( % ) of models trained with WideResNet-28-10
Method
CIFAR-10
CIFAR-100
Fashion-MNIST
EMNIST
Average
Vanilla (SGD)
94.08 ± 0.04
75.92 ± 0.39
87.84 ± 1.00
89.03 ± 0.20
86.72
SAM [ 11 ]
95.91 ± 0.04
79.15 ± 0.52
91.53 ± 0.30
89.16 ± 0.27
88.92
SS-SAM [ 40 ]
95.49 ± 0.25
80.19 ± 0.16
91.02 ± 0.96
88.41 ± 0.28
88.58
AE-SAM [ 16 ]
96.10 ± 0.46
79.22 ± 0.90
91.47 ± 0.33
89.38 ± 0.10
89.04
MSAM [ 1 ]
93.61 ± 0.35
77.49 ± 0.25
90.32 ± 0.30
88.39 ± 0.26
87.45
EMA
96.58 ± 0.05
80.74 ± 0.41
89.48 ± 0.38
86.78 ± 0.21
88.40
Table 5: Accuracies ( % ) of models trained with PyramidNet-110
Method
Top-1
Top-5
Vanilla (SGD)
76.45
93.22
SAM [ 11 ]
76.71
93.32
SS-SAM [ 40 ]
76.64
93.48
AE-SAM [ 16 ]
76.68
93.41
MSAM [ 1 ]
75.83
92.87
EMA
76.51
92.87
Table 6: Accuracies ( % ) of models trained with ResNet-50 on ImageNet-1k
Method
Top-1
Top-5
Vanilla (AdamW)
69.16
87.79
SAM [ 11 ]
71.19
89.21
SS-SAM [ 40 ]
69.58
88.28
AE-SAM [ 16 ]
72.06
89.97
MSAM [ 1 ]
71.59
89.48
EMA
71.04
89.42
Table 7: Accuracies ( % ) of models trained with ViT-B/16 on ImageNet-1k
Figure 2: Number of backpropagation per training step and test accuracy