Skip to content

Westlake-AI/SEMA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

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.

Catalog

This repo is mainly based on OpenMixup to implement classification, self-supervised learning, and regression tasks while using MMDetection, DDPM, OpenSTL, and fairseq for other tasks. Please watch us for the latest release!

  • Image Classification on ImageNet-1K and CIFAR-100 in OpenMixup. [configs]
  • Self-supervised Learning with Contrastive Learning Methods in OpenMixup.
  • Self-supervised Learning with Masked Image Modeling Methods in OpenMixup.
  • Object Detection and Segmentation on COCO. [code]
  • Image Generation on CIFAR-10 and CelebA-Align. [code]
  • Visual Regression on AgeDB, IMDB-WIKI, and RCFMNIST in OpenMixup.
  • Video Prediction on Moving-MNIST [code].

Installation

Please check INSTALL.md for installation instructions.

Experimental Results

TODO!

(back to top)

License

This project is released under the Apache 2.0 license.

Acknowledgement

Our implementation is mainly based on the following codebases. We gratefully thank the authors for their wonderful works.

  • OpenMixup: Open-source toolbox for visual representation learning.
  • MMDetection: OpenMMLab Detection Toolbox and Benchmark.
  • OpenSTL: A Comprehensive Benchmark of Spatio-Temporal Predictive Learning.
  • fairseq: Facebook AI Research Sequence-to-Sequence Toolkit written in Python.

Citation

If you find this repository helpful, please consider citing:

@inproceedings{Li2024SwitchEMA,
  title={Switch EMA: A Free Lunch for Better Flatness and Sharpness},
  author={Siyuan Li and Zicheng Liu and Juanxi Tian and Ge Wang and Zedong Wang and Weiyang Jin and Di Wu and Cheng Tan and Tao Lin and Yang Liu and Baigui Sun and Stan Z. Li},
  year={2024},
}

(back to top)