Awesome Open Source
Awesome Open Source


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 runs SE-ResNet20 with Cifar10 dataset.

  • python and python -m torch.distributed.launch --nproc_per_node=${NUM_GPUS} 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.


The codebase is tested on the following setting.

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

For training

To run or, you need


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

import torch.hub
hub_model = torch.hub.load(

Also, a pretrained SE-ResNet50 model is available.

import torch.hub
hub_model = torch.hub.load(



python [--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%


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

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

senet = se_resnet50(num_classes=1000)


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



authors' Caffe implementation

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (1,124,836
Pytorch (10,751
Related Projects