An open API service indexing awesome lists of open source software.

https://github.com/Westlake-AI/SEMA

Switch EMA: A Free Lunch for Better Flatness and Sharpness
https://github.com/Westlake-AI/SEMA

image-classification image-generation object-detection optimization pytorch regression regularization self-supervised-learning video-prediction

Last synced: 2 months ago
JSON representation

Switch EMA: A Free Lunch for Better Flatness and Sharpness

Awesome Lists containing this project

README

        


Switch EMA: A Free Lunch for Better Flatness and Sharpness

[Siyuan Li](https://lupin1998.github.io/)\*,1,2,3, [Zicheng Liu](https://pone7.github.io/)\*,1,3, [Juanxi Tian](https://openreview.net/profile?id=~Juanxi_Tian1)\*,1, [Ge Wang](https://openreview.net/profile?id=~Ge_Wang3)\*,1,3, [Zedong Wang](https://zedongwang.netlify.app/)1, [Weiyang Jin](https://openreview.net/profile?id=~Weiyang_Jin1)1, [Di Wu](https://scholar.google.com/citations?user=egz8bGQAAAAJ&hl=zh-CN)1,3, [Tao Lin](https://scholar.google.co.id/citations?hl=zh-CN&user=QE9pa_cAAAAJ)1, [Chen Tan](https://chengtan9907.github.io/)1,3, [Yang Liu](https://scholar.google.co.id/citations?user=t1emSE0AAAAJ&hl=zh-CN)2, [Baigui Sun](https://scholar.google.co.id/citations?user=ZNhTHywAAAAJ&hl=zh-CN)2, [Stan Z. Li](https://scholar.google.com/citations?user=Y-nyLGIAAAAJ&hl=zh-CN)†,1

1[Westlake University](https://westlake.edu.cn/), 2[Damo Academy](https://damo.alibaba.com/?language=en), 3[Zhejiang University](https://www.zju.edu.cn/english/)






## 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](https://github.com/Westlake-AI/openmixup) to implement classification, self-supervised learning, and regression tasks while using [MMDetection](https://github.com/open-mmlab/mmdetection/), DDPM, [OpenSTL](https://github.com/chengtan9907/OpenSTL), and [fairseq](https://github.com/facebookresearch/fairseq) for other tasks. **Please watch us for the latest release!**

- [x] **Image Classification** on ImageNet-1K and CIFAR-100 in [OpenMixup](https://github.com/Westlake-AI/openmixup/tree/main/configs/classification/imagenet/). [[configs](classification/)]
- [x] **Self-supervised Learning** with Contrastive Learning Methods in [OpenMixup](https://github.com/Westlake-AI/openmixup/tree/main/configs/selfsup).
- [x] **Self-supervised Learning** with Masked Image Modeling Methods in [OpenMixup](https://github.com/Westlake-AI/openmixup/tree/main/configs/selfsup).
- [ ] **Object Detection and Segmentation** on COCO. [[code](detection/)]
- [ ] **Image Generation** on CIFAR-10 and CelebA-Align. [[code](image_generation/)]
- [ ] **Visual Regression** on AgeDB, IMDB-WIKI, and RCFMNIST in [OpenMixup](https://github.com/Westlake-AI/openmixup/tree/main/configs/regression).
- [ ] **Video Prediction** on Moving-MNIST [[code](video_prediction/)].

## Installation
Please check [INSTALL.md](./openmixup/docs/en/install.md) for installation instructions.

## Experimental Results
TODO!

(back to top)

## License

This project is released under the [Apache 2.0 license](LICENSE).

## Acknowledgement

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

- [OpenMixup](https://github.com/Westlake-AI/openmixup): Open-source toolbox for visual representation learning.
- [MMDetection](https://github.com/open-mmlab/mmdetection): OpenMMLab Detection Toolbox and Benchmark.
- [OpenSTL](https://github.com/chengtan9907/OpenSTL): A Comprehensive Benchmark of Spatio-Temporal Predictive Learning.
- [fairseq](https://github.com/facebookresearch/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)