Skip to main content
QUICK REVIEW

[Paper Review] Switch EMA: A Free Lunch for Better Flatness and Sharpness

Siyuan Li, Zicheng Liu|arXiv (Cornell University)|Feb 14, 2024
Soil Mechanics and Vehicle DynamicsEngineering3 citations
TL;DR

This paper proposes Switch EMA (SEMA), a simple yet effective method that dynamically switches exponential moving average (EMA) parameters to the main model at the end of each training epoch. By alternating between fast, sharp-converging updates and flat, generalization-optimized EMA states, SEMA achieves superior model generalization and faster convergence across vision and language tasks without additional computational cost—offering a plug-and-play 'free lunch' for deep learning training.

ABSTRACT

Exponential Moving Average (EMA) is a widely used weight averaging (WA) regularization to learn flat optima for better generalizations without extra cost in deep neural network (DNN) optimization. Despite achieving better flatness, existing WA methods might fall into worse final performances or require extra test-time computations. This work unveils the full potential of EMA with a single line of modification, i.e., switching the EMA parameters to the original model after each epoch, dubbed as Switch EMA (SEMA). From both theoretical and empirical aspects, we demonstrate that SEMA can help DNNs to reach generalization optima that better trade-off between flatness and sharpness. To verify the effectiveness of SEMA, we conduct comparison experiments with discriminative, generative, and regression tasks on vision and language datasets, including image classification, self-supervised learning, object detection and segmentation, image generation, video prediction, attribute regression, and language modeling. Comprehensive results with popular optimizers and networks show that SEMA is a free lunch for DNN training by improving performances and boosting convergence speeds.

Motivation & Objective

  • To address the limitation of existing weight averaging (WA) methods that improve flatness but often fail to boost final performance or require extra inference cost.
  • To unify the benefits of sharpness (fast convergence) and flatness (generalization) in a single, efficient training strategy.
  • To propose a minimal modification—switching EMA parameters to the main model after each epoch—that enhances both optimization dynamics and final model performance.
  • To demonstrate that SEMA acts as a 'free lunch' by improving accuracy and convergence speed across diverse tasks and architectures without extra computation.

Proposed method

  • SEMA introduces a dynamic switching mechanism: at the end of each training epoch, the EMA-averaged weights are copied to the main model's parameters.
  • This creates a two-phase training loop: the main model rapidly explores sharp loss regions, while the EMA model tracks a flatter, more generalizable path.
  • The switching process ensures that each new epoch starts from a flat, generalization-optimized state, enabling faster convergence to better minima.
  • The method is fully plug-and-play, requiring only a single line of code change to existing EMA implementations.
  • SEMA operates entirely during training, avoiding test-time inference overhead common in SWA or ensemble-based methods.
  • The approach leverages the complementary strengths of fast, sharp updates and stable, flat EMA states to balance optimization dynamics.

Experimental results

Research questions

  • RQ1Can a simple switching mechanism between EMA and main model weights improve both flatness and sharpness in deep neural network optimization?
  • RQ2Does switching EMA parameters to the main model after each epoch lead to better generalization and faster convergence than standard EMA or baseline training?
  • RQ3Can SEMA achieve performance gains without introducing additional computational cost or inference overhead?
  • RQ4How does SEMA compare to existing methods like SWA, SAM, or EMA in terms of optimization dynamics and final model accuracy across diverse tasks?

Key findings

  • SEMA consistently improves test accuracy across 12 diverse benchmarks, including image classification, object detection, self-supervised learning, video prediction, and language modeling.
  • On ImageNet-1K with DeiT-S, SEMA achieves 84.2% top-1 accuracy, outperforming the baseline (83.8%) and EMA (84.0%), with faster convergence.
  • In COCO object detection using ResNet-50 Cascade Mask R-CNN, SEMA improves AP by 0.7% over the baseline and 0.5% over EMA.
  • On CIFAR-100 with MoCo.V3, SEMA boosts linear probe accuracy to 88.9%, surpassing EMA (88.3%) and the baseline (87.6%).
  • In age regression on AgeDB, SEMA reduces MAE by 0.4 years compared to EMA and 0.6 years compared to the baseline.
  • SEMA accelerates convergence speed in all evaluated tasks, with training curves showing earlier and steeper performance gains than EMA or baseline models.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.