Dynamic Dual Gating Neural Networks
This repository contains the PyTorch implementation for
Dynamic Dual Gating Neural Networks
Fanrong Li, Gang Li, Xiangyu He, Jian Cheng
ICCV 2021 Oral
Getting Started
Requirements
The main requirements of this work are:
- Python 3.7
- PyTorch == 1.5.0
- Torchvision == 0.6.0
- CUDA 10.2
We recommand using conda env to setup the experimental environments.
# Create environment
conda create -n DGNet python=3.7
conda activate DGNet
# Install PyTorch & Torchvision
pip install torch==1.5.0 torchvision==0.6.0
# Clone repo
git clone https://github.com/anonymous-9800/DGNet.git ./DGNet
cd ./DGNet
# Install other requirements
pip install -r requirements.txt
Trained models
Our trained models can be found here: Google Drive. Unzip and place them into the DGNet folder.
Evaluate a trained DGNet
# CIFAR-10
sh ./scripts/cifar_e.sh [ARCH] [PATH-TO-DATASET] [GPU-IDs] [PATH-TO-SAVE] [PATH-TO-TRAINED-MODEL]
# ResNet on ImageNet
sh ./scripts/imagenet_e.sh [ARCH] [PATH-TO-DATASET] [GPU-IDs] [PATH-TO-SAVE] [PATH-TO-TRAINED-MODEL]
# Example
sh ./scripts/imagenet_e.sh resdg34 [PATH-TO-DATASET] 0 imagenet/resdg34-04-e ./trained_models_cls/imagenet_results/resdg34/sparse06/resdg34_04.pth.tar
Train a DGNet
# CIFAR-10
sh ./scripts/cifar_t.sh [ARCH] [PATH-TO-DATASET] [TARGET-DENSITY] [GPU-IDs] [PATH-TO-SAVE] [PATH-TO-PRETRAINED-MODEL]
# ResNet on ImageNet
sh ./scripts/imagenet_t.sh [ARCH] [PATH-TO-DATASET] [TARGET-DENSITY] [GPU-IDs] [PATH-TO-SAVE]
# Example
sh ./scripts/imagenet_t.sh resdg34 [PATH-TO-DATASET] 0.4 0,1 imagent/resdg34-04
Main results
Model | Method | Top-1 (%) | Top-5 (%) | FLOPs | Google Drive |
ResNet-18 | DGNet (50%) | 70.12 | 89.22 | 9.54E8 | Link |
DGNet (60%) | 69.38 | 88.94 | 7.88E8 | Link | |
ResNet-34 | DGNet (60%) | 73.01 | 90.99 | 1.50E9 | Link |
DGNet (70%) | 71.95 | 90.46 | 1.21E9 | Link | |
ResNet-50 | DGNet (60%) | 76.41 | 93.05 | 1.65E9 | Link |
DGNet (70%) | 75.12 | 92.34 | 1.31E9 | Link | |
MobileNet-V2 | DGNet (50%) | 71.62 | 90.05 | 1.60E8 | Link |
Citation
If you find this project useful for your research, please use the following BibTeX entry.
@inproceedings{dgnet,
title={Dynamic Dual Gating Neural Networks},
author={Li, Fanrong and Li, Gang and He, Xiangyu and Cheng, Jian},
booktitle={Proceedings of the IEEE International Conference on Computer Vision (ICCV)},
year={2021}
}
Contact
For any questions, feel free to contact: lifanrong2017@ia.ac.cn