Combining Adam and its Inverse Counterpart to Enhance Generalization of Deep Learning Optimizers
Authors: Tao Shi, Liangming Chen, Long Jin, Mengchu Zhou
Organizations: School of Information Science and Engineering, Lanzhou University, Lanzhou 730000, China · Helen and John C. Hartmann Department of Electrical and Computer Engineering, New Jersey Institute of Technology, Newark, NJ 07102, USA
In the training of neural networks, adaptive moment estimation (Adam) typically converges fast but exhibits suboptimal generalization performance. A widely accepted explanation for its defect in generalization is that it often tends to converge to sharp minima. To enhance its ability to find flat minima, we propose its new variant named inverse Adam (InvAdam). The key improvement of InvAdam lies in its parameter update mechanism, which is opposite to that of Adam. Specifically, it computes element-wise multiplication of the first-order and second-order moments, while Adam computes the element-wise division of these two moments. This modification aims to increase the step size of the parameter update when the elements in the second-order moments are large and vice versa, which helps the parameter escape sharp minima and stay at flat ones. However, InvAdam's update mechanism may face challenges in convergence. To address this challenge, we propose dual Adam (DualAdam), which integrates the update mechanisms of both Adam and InvAdam, ensuring convergence while enhancing generalization performance. Additionally, we introduce the diffusion theory to mathematically demonstrate InvAdam's ability to escape sharp minima. Extensive experiments are conducted on image classification tasks and large language model (LLM) fine-tuning. The results validate that DualAdam outperforms Adam and its state-of-the-art variants in terms of generalization performance. The code is publicly available at https://github.com/LongJin-lab/DualAdam.
Figures & tables
Fig. 1: Mian idea of DualAdam. (a) The relationship between sharp minimum ϕ and flat one ψ . χ is the saddle point between ϕ and ψ ; (b) The update mechanisms of Adam and InvAdam. m^ and v^ are the bias-corrected first- and second-order moments, respectively. Subscript i represents the i -th element in the vector. Δθi is the i -th element in parameter update in one iteration; and (c) The update mechanism of DualAdam.
Fig. 2: Optimization trajectories of InvAdam and Adam on 2-parameter loss landscapes. The red stars represent the start points, and the black circles represent the end points.
Fig. 3: Test accuracies over epochs on CIFAR-100.
Model
Optimizer
CIFAR-10
CIFAR-100
Test Accuracy (%)
Training Time
Test Accuracy (%)
Training Time
ResNet-18
Adam [ 10 ]
93.66±0.17
36min40s
72.56±0.08
36min37s
AdamW [ 17 ]
94.09±0.04
36min43s
72.81±0.10
37min10s
SWATS [ 21 ]
92.96±1.04
43min27s
71.40±1.50
44min04s
NAdam [ 19 ]
94.01±0.02
37min12s
72.06±0.43
37min35s
RAdam [ 18 ]
94.11±0.01
37min11s
74.79±0.06
36min50s
TABLE I: Top-1 test accuracies (mean±std) and training times on CIFAR-10 and CIFAR-100
Model
Optimizer
Test accuracy (%)
Traning Time
ResNet-18
Adam [ 10 ]
50.98±0.42
537min24s
AdamW [ 17 ]
51.20±0.28
536min18s
SWATS [ 21 ]
49.55±0.45
601min18s
NAdam [ 19 ]
51.58±0.08
538min13s
RAdam [ 18 ]
55.04±0.32
537min06s
Adan [ 20 ]
51.97±0.21
540min18s
TABLE II: Test accuracies (mean±std) on Tiny ImageNet
Model
Optimizer
Test Accuracy (%)
ResNet-18
Adam [ 10 ]
69.55
AdamW [ 17 ]
71.29
DualAdam (ours)
72.61
ResNet-50
Adam [ 10 ]
70.10
AdamW [ 17 ]
71.23
DualAdam (ours)
73.32
TABLE III: Test accuracies on ImageNet-1k
Fig. 4: Comparisons of training loss, validation perplexity, and generalization gap of DualAdam and AdamW on the fine-tuning of OpenPangu-1B.
Fig. 5: Comparisons of top Hessian matrix’s eigenvalues, Hessian matrix’s traces, and Hessian matrix’s eigenvalue densities of loss landscapes on the CIFAR-100 dataset using ResNet18.
Fig. 6: Visualization of loss landscapes of Adam and DualAdam. The loss is defined as L(θ⋆+ζl) , where ζ is a scalar that scales the random vector l drawn from a Gaussian distribution to perturb the optimal parameter θ⋆ .
Switching Rate
Traning Loss
Validation Accuracy (%)
0
4.58±0.01
2.0±0.04
1×10−5
5.4±0.35×10−4
69.04±0.08
2×10−5
5.5±0.77×10−4
70.30±0.26
3×10−5
4.8±0.07×10−4
71.04±0.08
4×10−5
5.1±0.35×10−4
71.49±0.21
5×10−5
4.8±0.14×10−4
71.52±0.28
TABLE IV: Training losses (mean±std) and validation accuracies (mean±std) of DualAdam on CIFAR-100 using ResNet-18 with different switching rates
Linear Switching
Switching Rate
Test Accuracy (%)
5×10−5
75.30±0.34
8×10−5
75.29±0.21
1×10−4
75.13±0.16
Exponential Switching
Exponential Base
Test Accuracy (%)
0.8
71.45±0.47
0.9
72.82±0.09
TABLE V: Test accuracies (mean±std) of DualAdam on CIFAR-100 using ResNet-18 with different switching mechanisms
Generalization remains a pivotal challenge in deep learning, where traditional optimizers like Stochastic Gradient Descent (SGD) often converge to sharp minima, leading to overfitting and reduced performance on unseen data. Building on Sharpness-Aware Minimization (SAM), for seeking flat minima associated with improved generalization, we propose the Extragradient-Inspired Sharpness-Aware Minimization (EISAM), a novel optimizer that enhances generalization via the extragradient technique. EISAM uses a two-step update process: a prediction step investigating the geometry of the loss landscape and a perturbation step that refines updates with a base optimizer. This approach achieves better generalization performance than SAM. Crucially, EISAM reduces sensitivity to the perturbation radius, enhancing robustness, and simplifying the tuning across diverse settings. Extensive experiments on benchmark datasets demonstrate that EISAM consistently outperforms SGD, Adaptive Moment Estimation (Adam), and SAM in test accuracy and training efficiency across various architectures. Theoretical analysis further confirms that EISAM tightens the generalization bound by steering parameters toward flatter minima with reduced curvature. Accompanied by a thorough hyperparameter analysis, EISAM offers practical tuning guidance, establishing it as a robust, scalable, and broadly applicable optimization solution that advances both the theory and practice in deep learning.
Yao Fu, Chunxia Zhang, Junmin Liu +3
School of Mathematics and Statistics, Xi’an Jiaotong University, Xi’an, 710049, China · SGIT AI Lab, State Grid Corporation of China, Xi’an, 710054, China · School of Software, Xi’an Jiaotong University, Xi’an, 710049, China +2
Adam and AdamW are a class of default optimizers for training deep learning models in machine learning. These adaptive algorithms converge faster but generalize worse compared to SGD. In fact, their proved generalization error O(N1) also is larger than O(N1) of SGD, where N denotes training sample size. Recently, although some variants of Adam have been proposed to improve its generalization, their improved generalizations are still unexplored in theory. To fill this gap, in the paper, we restudy generalization of Adam and AdamW via algorithmic stability, and first prove that Adam and AdamW without square-root (i.e., Adam(W)-srf) have a generalization error O(Nρ^−2T), where T denotes iteration number and ρ^>0 denotes the smallest element of second-order momentum plus a small positive number. To improve generalization, we propose a class of efficient clever Adam (i.e., HomeAdam(W)) algorithms via sometimes returning momentum-based SGD. Moreover, we prove that our HomeAdam(W) have a smaller generalization error O(N1) than O(Nρ^−2T) of Adam(W)-srf, since ρ^ is generally very small. In particular, it is also smaller than the existing O(N1) of Adam(W). Meanwhile, we prove our HomeAdam(W) have a faster convergence rate of O(T1/41) than O(T1/4ρ˘−1) of the Adam(W)-srf, where ρ˘≤ρ^ also is very small. Extensive numerical experiments demonstrate efficiency of our HomeAdam(W) algorithms.
Feihu Huang, Guanyi Zhang, Songcan Chen
College of Computer Science and Technology, Nanjing University of Aeronautics and Astronautics, Nanjing, China · MIIT Key Laboratory of Pattern Analysis and Machine Intelligence, Nanjing, China
Adaptive optimizers such as Adam and non-adaptive methods like SGD exhibit distinct generalization capabilities across different architectures. Prior tunable optimizers attempt to bridge this gap by strictly interpolating between SGD and Adam, effectively confining adaptivity within the 0-to-1 bound. However, this restricted interpolation is fundamentally insufficient: we reveal that optimal adaptivity often requires extrapolation, such as negative adaptivity for classical CNNs and adaptivity of at least one (γ≥1) for Transformers. Extrapolating adaptivity theoretically violates the strict non-decreasing pre-conditioner assumption, often leading to divergence in existing methods. To break this barrier, we propose Anon, an optimizer that achieves fully continuous adaptivity extrapolation across the entire real-number spectrum. To guarantee provable stability in these out-of-bound regimes, we introduce Incremental Delay Update (IDU), a novel mechanism that bypasses hard max-tracking strategies. We theoretically establish Anon's convergence in both convex and non-convex settings. Empirically, by exploring previously unreachable adaptivity landscapes, Anon demonstrates highly competitive and scalable performance among state-of-the-art element-wise optimizers on representative image classification, diffusion, and large language modeling tasks.
Yiheng Zhang, Kaiyan Zhao, Shaowu Wu +5
Wuhan University · University of Macau · University of Calgary