All Projects → hiyouga → AMP-Regularizer

hiyouga / AMP-Regularizer

Licence: MIT License
Code for our paper "Regularizing Neural Networks via Adversarial Model Perturbation", CVPR2021

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to AMP-Regularizer

Petridishnn
Code for the neural architecture search methods contained in the paper Efficient Forward Neural Architecture Search
Stars: ✭ 112 (+330.77%)
Mutual labels:  deep-learning-algorithms, image-classification
SGGpoint
[CVPR 2021] Exploiting Edge-Oriented Reasoning for 3D Point-based Scene Graph Analysis (official pytorch implementation)
Stars: ✭ 41 (+57.69%)
Mutual labels:  cvpr, cvpr2021
LBYLNet
[CVPR2021] Look before you leap: learning landmark features for one-stage visual grounding.
Stars: ✭ 46 (+76.92%)
Mutual labels:  cvpr, cvpr2021
CoMoGAN
CoMoGAN: continuous model-guided image-to-image translation. CVPR 2021 oral.
Stars: ✭ 139 (+434.62%)
Mutual labels:  cvpr, cvpr2021
CVPR2021-Papers-with-Code-Demo
收集 CVPR 最新的成果,包括论文、代码和demo视频等,欢迎大家推荐!
Stars: ✭ 752 (+2792.31%)
Mutual labels:  cvpr, cvpr2021
Cvpr2021 Paper Code Interpretation
cvpr2021/cvpr2020/cvpr2019/cvpr2018/cvpr2017 论文/代码/解读/直播合集,极市团队整理
Stars: ✭ 8,075 (+30957.69%)
Mutual labels:  image-classification, cvpr2021
cfvqa
[CVPR 2021] Counterfactual VQA: A Cause-Effect Look at Language Bias
Stars: ✭ 96 (+269.23%)
Mutual labels:  cvpr, cvpr2021
Scan2Cap
[CVPR 2021] Scan2Cap: Context-aware Dense Captioning in RGB-D Scans
Stars: ✭ 81 (+211.54%)
Mutual labels:  cvpr, cvpr2021
cvpr-buzz
🐝 Explore Trending Papers at CVPR
Stars: ✭ 37 (+42.31%)
Mutual labels:  cvpr, cvpr2021
single-positive-multi-label
Multi-Label Learning from Single Positive Labels - CVPR 2021
Stars: ✭ 63 (+142.31%)
Mutual labels:  cvpr, cvpr2021
Cvpr2021 Papers With Code
CVPR 2021 论文和开源项目合集
Stars: ✭ 7,138 (+27353.85%)
Mutual labels:  cvpr, cvpr2021
Modaily-Aware-Audio-Visual-Video-Parsing
Code for CVPR 2021 paper Exploring Heterogeneous Clues for Weakly-Supervised Audio-Visual Video Parsing
Stars: ✭ 19 (-26.92%)
Mutual labels:  cvpr, cvpr2021
HistoGAN
Reference code for the paper HistoGAN: Controlling Colors of GAN-Generated and Real Images via Color Histograms (CVPR 2021).
Stars: ✭ 158 (+507.69%)
Mutual labels:  cvpr, cvpr2021
Deep-Learning
It contains the coursework and the practice I have done while learning Deep Learning.🚀 👨‍💻💥 🚩🌈
Stars: ✭ 21 (-19.23%)
Mutual labels:  deep-learning-algorithms, image-classification
Restoring-Extremely-Dark-Images-In-Real-Time
The project is the official implementation of our CVPR 2021 paper, "Restoring Extremely Dark Images in Real Time"
Stars: ✭ 79 (+203.85%)
Mutual labels:  cvpr, cvpr2021
BCNet
Deep Occlusion-Aware Instance Segmentation with Overlapping BiLayers [CVPR 2021]
Stars: ✭ 434 (+1569.23%)
Mutual labels:  cvpr, cvpr2021
MetaBIN
[CVPR2021] Meta Batch-Instance Normalization for Generalizable Person Re-Identification
Stars: ✭ 58 (+123.08%)
Mutual labels:  cvpr, cvpr2021
AODA
Official implementation of "Adversarial Open Domain Adaptation for Sketch-to-Photo Synthesis"(WACV 2022/CVPRW 2021)
Stars: ✭ 44 (+69.23%)
Mutual labels:  cvpr, cvpr2021
CADA
Attending to Discriminative Certainty for Domain Adaptation
Stars: ✭ 17 (-34.62%)
Mutual labels:  cvpr
Swin-Transformer
This is an official implementation for "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows".
Stars: ✭ 8,046 (+30846.15%)
Mutual labels:  image-classification

AMP-Regularizer

GitHub

PWC

A PyTorch implementation for our CVPR 2021 paper "Regularizing Neural Networks via Adversarial Model Perturbation".

You can download the paper via: [ArXiv] [PapersWithCode].

Poster and Slides can be found here.

One-Sentence Summary

Adversarial Model Perturbation (AMP) effectively improves the generalization performance of deep models by minimizing an "AMP loss" that can find flat local minima via applying a "worst" norm-bounded perturbation on the model parameter.

method

Abstract

Effective regularization techniques are highly desired in deep learning for alleviating overfitting and improving generalization. This work proposes a new regularization scheme, based on the understanding that the flat local minima of the empirical risk cause the model to generalize better. This scheme is referred to as adversarial model perturbation (AMP), where instead of directly minimizing the empirical risk, an alternative "AMP loss" is minimized via SGD. Specifically, the AMP loss is obtained from the empirical risk by applying the "worst" norm-bounded perturbation on each point in the parameter space. Comparing with most existing regularization schemes, AMP has strong theoretical justifications, in that minimizing the AMP loss can be shown theoretically to favour flat local minima of the empirical risk. Extensive experiments on various modern deep architectures establish AMP as a new state of the art among regularization schemes.

Requirement

  • Python >= 3.7
  • Torch >= 1.6.0
  • TorchVision >= 0.7.0
  • NumPy >= 1.18.5
  • Pillow >= 6.1.0

Preparation

Clone

git clone https://github.com/hiyouga/AMP-Regularizer.git

Create an anaconda environment:

conda create -n amp python=3.7
conda activate amp
pip install -r requirements.txt

Usage

You can use AMP as a regular optimizer with a closure function.

from amp import AMP

optimizer = AMP(model.parameters(), lr=0.1, epsilon=0.5, momentum=0.9)

for inputs, targets in dataset:
    def closure():
        optimizer.zero_grad()
        outputs = model(inputs)
        loss = loss_fn(outputs, targets)
        loss.backward()
        return outputs, loss

    outputs, loss = optimizer.step(closure)

Run an example:

python main.py --dataset cifar100 --model preactresnet18 --epsilon 0.5 --inner_lr 1 --inner_iter 1

Documentation

AMP(params, lr, epsilon, inner_lr=1, inner_iter=1, base_optimizer=SGD, **kwargs)

Implements adversarial model perturbation.

Argument Description
params (iterable) iterable of trainable parameters
lr (float) learning rate for outer optimization
epsilon (float) perturbation norm ball radius
inner_lr (float, optional) learning rate for inner optimization (default: 1)
inner_iter (int, optional) iteration number for inner optimization (default: 1)
base_optimizer (class, optional) basic optimizer class (default: SGD)
**kwargs keyword arguments passed to the __init__ method of base_optimizer

AMP.step(closure)

Performs AMP optimization step. Noting that AMP requires a closure to perform a optimization step.

Argument Description
closure (callable, required) a closure-based function that does a full forward-backward pass on the optimized model

Results

We conduct experiment on CIFAR-100 using WideResNet-28-10 with epsilon=0.5 and inner_lr=1. When we adopt inner_iter=1, AMP requires two gradient computation in each forward-backward pass. Thus it usually takes 1.8 times longer than ERM training.

Optimizer Test error
SGD + momentum 19.17±0.270
SGD + momentum (AMP) 17.33±0.110

File Specifications

  • models: Description for several model architectures.
  • data_utils.py: Used functions for data preprocessing.
  • main.py: Scripts for training the models.
  • amp.py: Implementation for adversarial model perturbation.

Citation

If this work is helpful, please cite as:

@inproceedings{zheng2020regularizing,
  title={Regularizing Neural Networks via Adversarial Model Perturbation},
  author={Zheng, Yaowei and Zhang, Richong and Mao, Yongyi},
  booktitle={{CVPR}},
  year={2021}
}

Acknowledgements

This work is supported partly by the National Key Research and Development Program of China, by the National Natural Science Foundation of China, by the Beijing Advanced Innovation Center for Big Data and Brain Computing (BDBC), by the Fundamental Research Funds for the Central Universities, by the Beijing S&T Committee and by the State Key Laboratory of Software Development Environment. The authors specially thank Linfang Hou for helpful discussions.

Contact

hiyouga [AT] buaa [DOT] edu [DOT] cn

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].