• Stars
    star
    2,128
  • Rank 21,688 (Top 0.5 %)
  • Language
    Python
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PyTorch implementation of SENet

SENet.pytorch

An implementation of SENet, proposed in Squeeze-and-Excitation Networks by Jie Hu, Li Shen and Gang Sun, who are the winners of ILSVRC 2017 classification competition.

Now SE-ResNet (18, 34, 50, 101, 152/20, 32) and SE-Inception-v3 are implemented.

  • python cifar.py runs SE-ResNet20 with Cifar10 dataset.

  • python imagenet.py and python -m torch.distributed.launch --nproc_per_node=${NUM_GPUS} imagenet.py run SE-ResNet50 with ImageNet(2012) dataset,

    • You need to prepare dataset by yourself in ~/.torch/data or set an enviroment variable IMAGENET_ROOT=${PATH_TO_YOUR_IMAGENET}
    • First download files and then follow the instruction.
    • The number of workers and some hyper parameters are fixed so check and change them if you need.
    • This script uses all GPUs available. To specify GPUs, use CUDA_VISIBLE_DEVICES variable. (e.g. CUDA_VISIBLE_DEVICES=1,2 to use GPU 1 and 2)

For SE-Inception-v3, the input size is required to be 299x299 as the original Inception.

Pre-requirements

The codebase is tested on the following setting.

  • Python>=3.8
  • PyTorch>=1.6.0
  • torchvision>=0.7

For training

To run cifar.py or imagenet.py, you need

hub

You can use some SE-ResNet (se_resnet{20, 56, 50, 101}) via torch.hub.

import torch.hub
hub_model = torch.hub.load(
    'moskomule/senet.pytorch',
    'se_resnet20',
    num_classes=10)

Also, a pretrained SE-ResNet50 model is available.

import torch.hub
hub_model = torch.hub.load(
    'moskomule/senet.pytorch',
    'se_resnet50',
    pretrained=True,)

Results

SE-ResNet20/Cifar10

python cifar.py [--baseline]

Note that the CIFAR-10 dataset expected to be under ~/.torch/data.

ResNet20 SE-ResNet20 (reduction 4 or 8)
max. test accuracy 92% 93%

SE-ResNet50/ImageNet

python [-m torch.distributed.launch --nproc_per_node=${NUM_GPUS}] imagenet.py

The option [-m ...] is for distributed training. Note that the Imagenet dataset is expected to be under ~/.torch/data or specified as IMAGENET_ROOT=${PATH_TO_IMAGENET}.

The initial learning rate and mini-batch size are different from the original version because of my computational resource .

ResNet SE-ResNet
max. test accuracy(top1) 76.15 %(*) 77.06% (**)
# !wget https://github.com/moskomule/senet.pytorch/releases/download/archive/seresnet50-60a8950a85b2b.pkl

senet = se_resnet50(num_classes=1000)
senet.load_state_dict(torch.load("seresnet50-60a8950a85b2b.pkl"))

Contribution

I cannot maintain this repository actively, but any contributions are welcome. Feel free to send PRs and issues.

References

paper

authors' Caffe implementation

More Repositories

1

ewc.pytorch

An implementation of EWC with PyTorch
Jupyter Notebook
181
star
2

dda

Differentiable Data Augmentation Library
Jupyter Notebook
115
star
3

sam.pytorch

A PyTorch implementation of Sharpness-Aware Minimization for Efficiently Improving Generalization
Python
110
star
4

homura

homura is a library for fast prototyping DL research
Python
104
star
5

shampoo.pytorch

An implementation of shampoo
Python
72
star
6

cca.pytorch

CCAs for looking into DNNs
Python
69
star
7

pytorch.rl.learning

for learning reinforcement learning using PyTorch.
Python
65
star
8

anatome

แผˆฮฝฮฑฯ„ฮฟฮผฮฎ is a PyTorch library to analyze representation of neural networks
Jupyter Notebook
55
star
9

l0.pytorch

an implementation of L0 regularization with PyTorch
Jupyter Notebook
52
star
10

ssl-suite

SSL using PyTorch
Python
50
star
11

mixup.pytorch

an implementation of mixup
Python
39
star
12

pytorch.snapshot.ensembles

PyTorch implementation of "SNAPSHOT ENSEMBLES: TRAIN 1, GET M FOR FREE" [WIP]
Python
36
star
13

eve.pytorch

Python
32
star
14

simple_transformers

Simple transformer implementations that I can understand
Python
20
star
15

chika

chika is a simple and easy config tool for hierarchical configurations.
Python
20
star
16

distillation.pytorch

Implementation of several knowledge distillation techniques on PyTorch
Python
15
star
17

hypergrad

Simple and extensible hypergradient for PyTorch
Python
15
star
18

pytorch.detection.learning

learning object detection using pytorch
Jupyter Notebook
12
star
19

introvae.pytorch

Python
11
star
20

softdisc

Differentiable Discrete Algorithms for PyTorch
Python
9
star
21

memory_efficient_attention.pytorch

A human-readable PyTorch implementation of "Self-attention Does Not Need O(n^2) Memory" (Rabe&Staats'21).
Python
7
star
22

gsync

Simple PyDrive wrapper and command line tool.
Python
6
star
23

softsort.pytorch

PyTorch implementation of Cuturi M., Teboul O., Vert JP: Differentiable Sorting using Optimal Transport: The Sinkhorn CDF and Quantile Operator
Python
6
star
24

neuralcompressor.pytorch

PyTorch Implementation of Compressing Word Embeddings via Deep Compositional Code Learning
Python
5
star
25

dataset-contamination

Datasets of "Will Large-scale Generative Models Corrupt Future Datasets?"
4
star
26

mlp_mixer.pytorch

PyTorch implementation of "MLP-Mixer: An all-MLP Architecture for Vision"
Python
4
star
27

maguro

A simple job scheduler for GPUs
Python
4
star
28

pyproject_template

Python
3
star
29

abel.pytorch

PyTorch LR scheduler of ABEL
Python
3
star
30

jax_devcontainer

devcontainer for JAX
Jupyter Notebook
3
star
31

miniargs

A wrapper of argparse which I can remember the APIs.
Python
3
star
32

moskomule.github.io

HTML
3
star
33

.dotfiles

dotfiles
Shell
2
star
34

convnext.pytorch

ConvNeXt with hub
2
star
35

madoka

A simple wrapper of matplotlib for figures in papers
Jupyter Notebook
2
star
36

attentions.pytorch

Attentions for computer vision
Python
2
star
37

greedy-learning

To catch up the recent progress of layerwise learning
Python
2
star
38

honen

A wrapper of matplotlib for myself
Jupyter Notebook
2
star
39

hyperhomura

Gradient-based Hyperparameter Optimization for homura
2
star
40

functorch_utils

Utilities for functorch
1
star
41

cuda-server

Shell
1
star
42

LaTeX-better-practice

To avoid re-searching and re-inventing wheels
1
star
43

yax

JAX things
Dockerfile
1
star
44

black-box-optimization

Julia
1
star
45

moskomule

1
star
46

mine.pytorch

Python
1
star
47

mae.pytorch

A PyTorch implementation of Masked Autoencoders (WIP)
Python
1
star