Reproduces ResNet-V3 with pytorch

Overview

ResNeXt.pytorch

Reproduces ResNet-V3 (Aggregated Residual Transformations for Deep Neural Networks) with pytorch.

  • Tried on pytorch 1.6
  • Trains on Cifar10 and Cifar100
  • Upload Cifar Training Curves
  • Upload Cifar Trained Models
  • Pytorch 0.4.0
  • Train Imagenet

Download

git clone https://github.com/prlz77/resnext.pytorch
cd resnext.pytorch
# git checkout R4.0 or R3.0 for backwards compatibility (not recommended).

Usage

To train on Cifar-10 using 2 gpu:

python train.py ~/DATASETS/cifar.python cifar10 -s ./snapshots --log ./logs --ngpu 2 --learning_rate 0.05 -b 128

It should reach ~3.65% on Cifar-10, and ~17.77% on Cifar-100.

After train phase, you can check saved model.

Thanks to @AppleHolic we have now a test script:

To test on Cifar-10 using 2 gpu:

python test.py ~/DATASETS/cifar.python cifar10 --ngpu 2 --load ./snapshots/model.pytorch --test_bs 128 

Configurations

From the original paper:

cardinality base_width parameters Error cifar10 error cifar100 default
8 64 34.4M 3.65 17.77 x
16 64 68.1M 3.58 17.31

Update: widen_factor has been disentangled from base_width because it was confusing. Now widen factor is set to consant 4, and base_width is the same as in the original paper.

Trained models and curves

Link to trained models corresponding to the following curves:

Update: several commits have been pushed after training the models in Mega, so it is recommended to revert to e10c37d8cf7a958048bc0f58cd86c3e8ac4e707d

CIFAR-10 CIFAR-100

Other frameworks

Cite

@article{xie2016aggregated,
  title={Aggregated residual transformations for deep neural networks},
  author={Xie, Saining and Girshick, Ross and Doll{\'a}r, Piotr and Tu, Zhuowen and He, Kaiming},
  journal={arXiv preprint arXiv:1611.05431},
  year={2016}
}
Comments
  • OSError: [Errno 12] Cannot allocate memory

    OSError: [Errno 12] Cannot allocate memory

    Hello, I am getting Cannot allocate memory error;I understand this is something related to my GPU. But it is quite surprising that I should get this error because, I am training this on 3 1080TI GPUs, with a batch size of 64.

    Traceback (most recent call last):
      File "train.py", line 162, in <module>
        train()
      File "train.py", line 113, in train
        for batch_idx, (data, target) in enumerate(train_loader):
      File "/usr/local/torch3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 310, in __iter__
        return DataLoaderIter(self)
      File "/usr/local/torch3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 167, in __init__
        w.start()
      File "/usr/lib/python3.5/multiprocessing/process.py", line 105, in start
        self._popen = self._Popen(self)
      File "/usr/lib/python3.5/multiprocessing/context.py", line 212, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "/usr/lib/python3.5/multiprocessing/context.py", line 267, in _Popen
        return Popen(process_obj)
      File "/usr/lib/python3.5/multiprocessing/popen_fork.py", line 20, in __init__
        self._launch(process_obj)
      File "/usr/lib/python3.5/multiprocessing/popen_fork.py", line 67, in _launch
        self.pid = os.fork()
    OSError: [Errno 12] Cannot allocate memory
    

    CUDA_VISIBLE_DEVICES=0,1,2 python train.py ~/DATASETS/cifar.python cifar10 -s ./snapshots --log ./logs --ngpu 3 --learning_rate 0.05 -b 64

    Please suggest what I could do to avoid this issue. Thank You!

    opened by nbansal90 12
  • question about the input img size

    question about the input img size

    hey! I am confused with the input size of the training data. I train a dataset which input size is (3,112,112), should I have to make some changes to the model?

    opened by yuzehui1996 8
  • question about the dimension of the net

    question about the dimension of the net

    If the input of the net is of 643224224 dimension,where 64 is the batch size,3 is the channels and 224 is the size of the original image,and i run the code and find out that the output's dimension of the net is 480210,where 10 is the classes to predict. Is the output correct?Shouldn't the dimension of the output be 64*10? Maybe i get something wrong?

    opened by Agito555 4
  • Pretrained model link broken

    Pretrained model link broken

    In the README, link to the CIFAR trained models (https://mega.nz/#F!wbJXDS6b!YN3hCDi1tT3SdNFrLPm7mA) is broken. Can you check and share the pretrained models?

    Thanks :)

    opened by coallaoh 4
  • Question about the number of channels

    Question about the number of channels

    Hi, May I ask you a question? Why are the output channels of conv_reduce four times the number of input channels and how it can play the role of reducing dimensions before 3*3 convolution?

    CifarResNeXt ( (conv_1_3x3): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False) (bn_1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True) (stage_1): Sequential ( (stage_1_bottleneck_0): ResNeXtBottleneck ( (conv_reduce): Conv2d(64, 512, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn_reduce): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True) (conv_conv): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), groups=8, bias=False) (bn): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True) (conv_expand): Conv2d(512, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) (bn_expand): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True) (shortcut): Sequential ( (shortcut_conv): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False) (shortcut_bn): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True) ) )

    opened by zl1994 4
  • TypeError: tensor(0, device='cuda:0') is not JSON serializable

    TypeError: tensor(0, device='cuda:0') is not JSON serializable

    when I run the codes following your instructions, "TypeError: tensor(0, device='cuda:0') is not JSON serializable" occurs at the line 167 of train.py, and it's the code "log.write('%s\n' % json.dumps(state))". I wonder whether it caused by the version of pytorch or the version of python? I use Pytorch 4.0 python 2.7 now.

    opened by zorrocai 3
  • About initial learning rate

    About initial learning rate

    Hi,

    May I know what's the initial learning rate used in Cifar10 and Cifar100 experiments (-b 128 on 2 GPU cards)? The default value 0.1 or the sample value 0.05? Many thanks in advance!

    opened by lld533 2
  • RuntimeError: Error(s) in loading state_dict for CifarResNeXt:

    RuntimeError: Error(s) in loading state_dict for CifarResNeXt:

    When I try to run test.py , I got this:

    Traceback (most recent call last):
      File "/home/ubuntu/bigdisk/part1/resnext.pytorch/test.py", line 114, in <module>
        test()
      File "/home/ubuntu/bigdisk/part1/resnext.pytorch/test.py", line 79, in test
        net.load_state_dict(loaded_state_dict)
      File "/home/ubuntu/anaconda3/envs/resnext/lib/python2.7/site-packages/torch/nn/modules/module.py", line 845, in load_state_dict
        self.__class__.__name__, "\n\t".join(error_msgs)))
    RuntimeError: Error(s) in loading state_dict for CifarResNeXt:
    	Missing key(s) in state_dict: "conv_1_3x3.weight", "bn_1.running_var", "bn_1.bias", "bn_1.weight", "bn_1.running_mean", "stage_1.stage_1_bottleneck_0.conv_reduce.weight", "stage_1.stage_1_bottleneck_0.bn_reduce.running_var", "stage_1.stage_1_bottleneck_0.bn_reduce.bias", "stage_1.stage_1_bottleneck_0.bn_reduce.weight", "stage_1.stage_1_bottleneck_0.bn_reduce.running_mean", "stage_1.stage_1_bottleneck_0.conv_conv.weight", "stage_1.stage_1_bottleneck_0.bn.running_var", "stage_1.stage_1_bottleneck_0.bn.bias", "stage_1.stage_1_bottleneck_0.bn.weight", "stage_1.stage_1_bottleneck_0.bn.running_mean", "stage_1.stage_1_bottleneck_0.conv_expand.weight", "stage_1.stage_1_bottleneck_0.bn_expand.running_var", "stage_1.stage_1_bottleneck_0.bn_expand.bias", "stage_1.stage_1_bottleneck_0.bn_expand.weight", "stage_1.stage_1_bottleneck_0.bn_expand.running_mean", "stage_1.stage_1_bottleneck_0.shortcut.shortcut_conv.weight", "stage_1.stage_1_bottleneck_0.shortcut.shortcut_bn.running_var", "stage_1.stage_1_bottleneck_0.shortcut.shortcut_bn.bias", "stage_1.stage_1_bottleneck_0.shortcut.shortcut_bn.weight", "stage_1.stage_1_bottleneck_0.shortcut.shortcut_bn.running_mean", "stage_1.stage_1_bottleneck_1.conv_reduce.weight", "stage_1.stage_1_bottleneck_1.bn_reduce.running_var", "stage_1.stage_1_bottleneck_1.bn_reduce.bias", "stage_1.stage_1_bottleneck_1.bn_reduce.weight", "stage_1.stage_1_bottleneck_1.bn_reduce.running_mean", "stage_1.stage_1_bottleneck_1.conv_conv.weight", "stage_1.stage_1_bottleneck_1.bn.running_var", "stage_1.stage_1_bottleneck_1.bn.bias", "stage_1.stage_1_bottleneck_1.bn.weight", "stage_1.stage_1_bottleneck_1.bn.running_mean", "stage_1.stage_1_bottleneck_1.conv_expand.weight", "stage_1.stage_1_bottleneck_1.bn_expand.running_var", "stage_1.stage_1_bottleneck_1.bn_expand.bias", "stage_1.stage_1_bottleneck_1.bn_expand.weight", "stage_1.stage_1_bottleneck_1.bn_expand.running_mean", "stage_1.stage_1_bottleneck_2.conv_reduce.weight", "stage_1.stage_1_bottleneck_2.bn_reduce.running_var", "stage_1.stage_1_bottleneck_2.bn_reduce.bias", "stage_1.stage_1_bottleneck_2.bn_reduce.weight", "stage_1.stage_1_bottleneck_2.bn_reduce.running_mean", "stage_1.stage_1_bottleneck_2.conv_conv.weight", "stage_1.stage_1_bottleneck_2.bn.running_var", "stage_1.stage_1_bottleneck_2.bn.bias", "stage_1.stage_1_bottleneck_2.bn.weight", "stage_1.stage_1_bottleneck_2.bn.running_mean", "stage_1.stage_1_bottleneck_2.conv_expand.weight", "stage_1.stage_1_bottleneck_2.bn_expand.running_var", "stage_1.stage_1_bottleneck_2.bn_expand.bias", "stage_1.stage_1_bottleneck_2.bn_expand.weight", "stage_1.stage_1_bottleneck_2.bn_expand.running_mean", "stage_2.stage_2_bottleneck_0.conv_reduce.weight", "stage_2.stage_2_bottleneck_0.bn_reduce.running_var", "stage_2.stage_2_bottleneck_0.bn_reduce.bias", "stage_2.stage_2_bottleneck_0.bn_reduce.weight", "stage_2.stage_2_bottleneck_0.bn_reduce.running_mean", "stage_2.stage_2_bottleneck_0.conv_conv.weight", "stage_2.stage_2_bottleneck_0.bn.running_var", "stage_2.stage_2_bottleneck_0.bn.bias", "stage_2.stage_2_bottleneck_0.bn.weight", "stage_2.stage_2_bottleneck_0.bn.running_mean", "stage_2.stage_2_bottleneck_0.conv_expand.weight", "stage_2.stage_2_bottleneck_0.bn_expand.running_var", "stage_2.stage_2_bottleneck_0.bn_expand.bias", "stage_2.stage_2_bottleneck_0.bn_expand.weight", "stage_2.stage_2_bottleneck_0.bn_expand.running_mean", "stage_2.stage_2_bottleneck_0.shortcut.shortcut_conv.weight", "stage_2.stage_2_bottleneck_0.shortcut.shortcut_bn.running_var", "stage_2.stage_2_bottleneck_0.shortcut.shortcut_bn.bias", "stage_2.stage_2_bottleneck_0.shortcut.shortcut_bn.weight", "stage_2.stage_2_bottleneck_0.shortcut.shortcut_bn.running_mean", "stage_2.stage_2_bottleneck_1.conv_reduce.weight", "stage_2.stage_2_bottleneck_1.bn_reduce.running_var", "stage_2.stage_2_bottleneck_1.bn_reduce.bias", "stage_2.stage_2_bottleneck_1.bn_reduce.weight", "stage_2.stage_2_bottleneck_1.bn_reduce.running_mean", "stage_2.stage_2_bottleneck_1.conv_conv.weight", "stage_2.stage_2_bottleneck_1.bn.running_var", "stage_2.stage_2_bottleneck_1.bn.bias", "stage_2.stage_2_bottleneck_1.bn.weight", "stage_2.stage_2_bottleneck_1.bn.running_mean", "stage_2.stage_2_bottleneck_1.conv_expand.weight", "stage_2.stage_2_bottleneck_1.bn_expand.running_var", "stage_2.stage_2_bottleneck_1.bn_expand.bias", "stage_2.stage_2_bottleneck_1.bn_expand.weight", "stage_2.stage_2_bottleneck_1.bn_expand.running_mean", "stage_2.stage_2_bottleneck_2.conv_reduce.weight", "stage_2.stage_2_bottleneck_2.bn_reduce.running_var", "stage_2.stage_2_bottleneck_2.bn_reduce.bias", "stage_2.stage_2_bottleneck_2.bn_reduce.weight", "stage_2.stage_2_bottleneck_2.bn_reduce.running_mean", "stage_2.stage_2_bottleneck_2.conv_conv.weight", "stage_2.stage_2_bottleneck_2.bn.running_var", "stage_2.stage_2_bottleneck_2.bn.bias", "stage_2.stage_2_bottleneck_2.bn.weight", "stage_2.stage_2_bottleneck_2.bn.running_mean", "stage_2.stage_2_bottleneck_2.conv_expand.weight", "stage_2.stage_2_bottleneck_2.bn_expand.running_var", "stage_2.stage_2_bottleneck_2.bn_expand.bias", "stage_2.stage_2_bottleneck_2.bn_expand.weight", "stage_2.stage_2_bottleneck_2.bn_expand.running_mean", "stage_3.stage_3_bottleneck_0.conv_reduce.weight", "stage_3.stage_3_bottleneck_0.bn_reduce.running_var", "stage_3.stage_3_bottleneck_0.bn_reduce.bias", "stage_3.stage_3_bottleneck_0.bn_reduce.weight", "stage_3.stage_3_bottleneck_0.bn_reduce.running_mean", "stage_3.stage_3_bottleneck_0.conv_conv.weight", "stage_3.stage_3_bottleneck_0.bn.running_var", "stage_3.stage_3_bottleneck_0.bn.bias", "stage_3.stage_3_bottleneck_0.bn.weight", "stage_3.stage_3_bottleneck_0.bn.running_mean", "stage_3.stage_3_bottleneck_0.conv_expand.weight", "stage_3.stage_3_bottleneck_0.bn_expand.running_var", "stage_3.stage_3_bottleneck_0.bn_expand.bias", "stage_3.stage_3_bottleneck_0.bn_expand.weight", "stage_3.stage_3_bottleneck_0.bn_expand.running_mean", "stage_3.stage_3_bottleneck_0.shortcut.shortcut_conv.weight", "stage_3.stage_3_bottleneck_0.shortcut.shortcut_bn.running_var", "stage_3.stage_3_bottleneck_0.shortcut.shortcut_bn.bias", "stage_3.stage_3_bottleneck_0.shortcut.shortcut_bn.weight", "stage_3.stage_3_bottleneck_0.shortcut.shortcut_bn.running_mean", "stage_3.stage_3_bottleneck_1.conv_reduce.weight", "stage_3.stage_3_bottleneck_1.bn_reduce.running_var", "stage_3.stage_3_bottleneck_1.bn_reduce.bias", "stage_3.stage_3_bottleneck_1.bn_reduce.weight", "stage_3.stage_3_bottleneck_1.bn_reduce.running_mean", "stage_3.stage_3_bottleneck_1.conv_conv.weight", "stage_3.stage_3_bottleneck_1.bn.running_var", "stage_3.stage_3_bottleneck_1.bn.bias", "stage_3.stage_3_bottleneck_1.bn.weight", "stage_3.stage_3_bottleneck_1.bn.running_mean", "stage_3.stage_3_bottleneck_1.conv_expand.weight", "stage_3.stage_3_bottleneck_1.bn_expand.running_var", "stage_3.stage_3_bottleneck_1.bn_expand.bias", "stage_3.stage_3_bottleneck_1.bn_expand.weight", "stage_3.stage_3_bottleneck_1.bn_expand.running_mean", "stage_3.stage_3_bottleneck_2.conv_reduce.weight", "stage_3.stage_3_bottleneck_2.bn_reduce.running_var", "stage_3.stage_3_bottleneck_2.bn_reduce.bias", "stage_3.stage_3_bottleneck_2.bn_reduce.weight", "stage_3.stage_3_bottleneck_2.bn_reduce.running_mean", "stage_3.stage_3_bottleneck_2.conv_conv.weight", "stage_3.stage_3_bottleneck_2.bn.running_var", "stage_3.stage_3_bottleneck_2.bn.bias", "stage_3.stage_3_bottleneck_2.bn.weight", "stage_3.stage_3_bottleneck_2.bn.running_mean", "stage_3.stage_3_bottleneck_2.conv_expand.weight", "stage_3.stage_3_bottleneck_2.bn_expand.running_var", "stage_3.stage_3_bottleneck_2.bn_expand.bias", "stage_3.stage_3_bottleneck_2.bn_expand.weight", "stage_3.stage_3_bottleneck_2.bn_expand.running_mean", "classifier.bias", "classifier.weight". 
    	Unexpected key(s) in state_dict: ".stage_1_bottleneck_0.bn.num_batches_tracked", ".stage_1_bottleneck_2.bn.bias", ".stage_1_bottleneck_1.bn_expand.bias", ".stage_2_bottleneck_0.shortcut.shortcut_bn.num_batches_tracked", ".stage_2_bottleneck_0.bn_expand.running_var", ".stage_2_bottleneck_1.bn_expand.bias", ".stage_3_bottleneck_0.bn_expand.running_mean", ".stage_3_bottleneck_2.bn.bias", ".stage_3_bottleneck_0.bn_reduce.weight", ".stage_2_bottleneck_0.bn.weight", ".stage_2_bottleneck_0.bn.running_mean", ".stage_2_bottleneck_0.shortcut.shortcut_bn.running_mean", ".stage_3_bottleneck_0.bn_reduce.num_batches_tracked", ".stage_2_bottleneck_1.bn_expand.running_mean", ".stage_2_bottleneck_0.bn.num_batches_tracked", ".stage_2_bottleneck_2.conv_expand.weight", ".stage_1_bottleneck_2.bn_expand.weight", ".stage_2_bottleneck_1.bn_expand.weight", ".stage_2_bottleneck_0.bn_reduce.running_var", ".stage_1_bottleneck_2.bn_expand.running_var", ".stage_1_bottleneck_0.bn.running_mean", ".stage_1_bottleneck_0.bn_reduce.running_var", ".stage_1_bottleneck_0.bn_reduce.weight", ".stage_2_bottleneck_1.bn.running_var", "ight", ".stage_2_bottleneck_2.bn_reduce.running_var", ".stage_2_bottleneck_0.bn_reduce.num_batches_tracked", ".stage_3_bottleneck_0.bn.running_mean", ".stage_2_bottleneck_2.bn_expand.running_var", ".stage_1_bottleneck_0.conv_reduce.weight", ".stage_2_bottleneck_1.bn_reduce.weight", ".stage_1_bottleneck_1.bn_expand.num_batches_tracked", ".stage_2_bottleneck_2.bn_reduce.weight", ".stage_3_bottleneck_0.shortcut.shortcut_bn.bias", ".stage_3_bottleneck_2.bn.weight", ".stage_1_bottleneck_1.bn.running_var", ".stage_1_bottleneck_1.bn_reduce.weight", ".stage_1_bottleneck_0.bn_expand.weight", ".stage_2_bottleneck_2.conv_conv.weight", ".stage_1_bottleneck_1.bn_expand.running_mean", ".stage_2_bottleneck_0.bn_expand.bias", ".stage_2_bottleneck_1.bn.bias", ".stage_3_bottleneck_1.bn_expand.num_batches_tracked", ".stage_2_bottleneck_2.bn.num_batches_tracked", ".stage_1_bottleneck_2.conv_conv.weight", ".stage_3_bottleneck_0.conv_conv.weight", ".stage_2_bottleneck_1.bn_reduce.running_var", ".stage_1_bottleneck_1.bn_expand.weight", ".stage_3_bottleneck_0.bn_expand.weight", ".stage_1_bottleneck_1.bn.weight", ".stage_3_bottleneck_0.bn.weight", ".stage_3_bottleneck_2.bn_reduce.weight", ".stage_1_bottleneck_2.bn.weight", ".stage_2_bottleneck_0.bn_expand.weight", ".stage_2_bottleneck_0.shortcut.shortcut_bn.weight", ".stage_1_bottleneck_2.bn.running_mean", ".stage_1_bottleneck_0.bn.weight", "nning_mean", ".stage_1_bottleneck_0.shortcut.shortcut_bn.running_var", ".stage_3_bottleneck_1.conv_reduce.weight", ".stage_2_bottleneck_2.bn_expand.num_batches_tracked", ".stage_2_bottleneck_2.bn_expand.weight", ".stage_1_bottleneck_2.bn_reduce.bias", ".stage_3_bottleneck_2.bn_reduce.num_batches_tracked", ".stage_1_bottleneck_1.conv_expand.weight", ".stage_3_bottleneck_1.bn_expand.bias", ".stage_3_bottleneck_1.conv_conv.weight", ".stage_1_bottleneck_2.bn.num_batches_tracked", ".stage_3_bottleneck_0.shortcut.shortcut_conv.weight", ".stage_3_bottleneck_0.shortcut.shortcut_bn.num_batches_tracked", ".stage_3_bottleneck_1.bn.running_var", ".stage_2_bottleneck_2.bn.running_mean", ".stage_2_bottleneck_0.bn_expand.num_batches_tracked", ".stage_3_bottleneck_1.bn_reduce.num_batches_tracked", ".stage_3_bottleneck_0.bn.running_var", ".stage_2_bottleneck_1.bn_reduce.running_mean", ".stage_3_bottleneck_0.shortcut.shortcut_bn.weight", ".stage_1_bottleneck_0.bn.bias", ".stage_1_bottleneck_2.bn_reduce.weight", ".stage_3_bottleneck_0.conv_expand.weight", ".stage_1_bottleneck_0.bn_reduce.num_batches_tracked", ".stage_3_bottleneck_2.bn.running_var", ".stage_3_bottleneck_2.conv_conv.weight", ".stage_3_bottleneck_2.bn_expand.running_var", ".stage_1_bottleneck_1.bn.num_batches_tracked", ".stage_3_bottleneck_0.bn.bias", ".stage_3_bottleneck_0.bn_reduce.running_mean", ".stage_2_bottleneck_0.bn_reduce.bias", ".stage_1_bottleneck_0.shortcut.shortcut_conv.weight", ".stage_2_bottleneck_2.bn.weight", ".stage_1_bottleneck_0.shortcut.shortcut_bn.running_mean", ".stage_3_bottleneck_1.bn_reduce.running_var", ".stage_2_bottleneck_0.bn_expand.running_mean", ".stage_2_bottleneck_1.bn_reduce.num_batches_tracked", ".stage_2_bottleneck_1.conv_reduce.weight", ".stage_2_bottleneck_0.bn_reduce.running_mean", ".stage_1_bottleneck_1.bn_expand.running_var", ".stage_1_bottleneck_1.bn_reduce.running_var", ".stage_3_bottleneck_1.bn_reduce.running_mean", ".stage_2_bottleneck_0.shortcut.shortcut_bn.bias", ".stage_2_bottleneck_2.bn_expand.running_mean", "ier.bias", ".stage_3_bottleneck_0.bn_expand.num_batches_tracked", ".stage_2_bottleneck_1.bn_expand.running_var", ".stage_3_bottleneck_0.bn_expand.bias", "3x3.weight", ".stage_3_bottleneck_1.bn.weight", ".stage_2_bottleneck_0.bn.bias", ".stage_1_bottleneck_0.shortcut.shortcut_bn.weight", ".stage_1_bottleneck_2.bn.running_var", ".stage_2_bottleneck_2.bn.bias", ".stage_2_bottleneck_2.conv_reduce.weight", ".stage_1_bottleneck_0.bn.running_var", ".stage_3_bottleneck_2.bn_expand.num_batches_tracked", ".stage_3_bottleneck_1.bn.num_batches_tracked", ".stage_1_bottleneck_0.bn_expand.running_mean", ".stage_3_bottleneck_1.bn_reduce.bias", ".stage_2_bottleneck_2.bn_expand.bias", ".stage_3_bottleneck_1.bn.bias", ".stage_2_bottleneck_2.bn_reduce.bias", ".stage_2_bottleneck_0.conv_conv.weight", ".stage_1_bottleneck_2.bn_expand.num_batches_tracked", ".stage_1_bottleneck_1.bn.bias", ".stage_2_bottleneck_1.bn.weight", ".stage_2_bottleneck_2.bn.running_var", ".stage_3_bottleneck_0.bn.num_batches_tracked", ".stage_1_bottleneck_0.conv_expand.weight", ".stage_1_bottleneck_1.conv_reduce.weight", ".stage_3_bottleneck_2.bn_expand.weight", ".stage_2_bottleneck_1.conv_conv.weight", ".stage_1_bottleneck_1.bn_reduce.num_batches_tracked", ".stage_1_bottleneck_2.bn_expand.bias", ".stage_2_bottleneck_1.conv_expand.weight", ".stage_3_bottleneck_0.conv_reduce.weight", ".stage_1_bottleneck_0.bn_expand.num_batches_tracked", ".stage_2_bottleneck_1.bn_expand.num_batches_tracked", ".stage_3_bottleneck_2.conv_expand.weight", ".stage_2_bottleneck_1.bn.num_batches_tracked", "ier.weight", ".stage_3_bottleneck_2.bn_expand.bias", ".stage_3_bottleneck_2.bn_reduce.bias", ".stage_3_bottleneck_2.bn.num_batches_tracked", ".stage_1_bottleneck_2.conv_expand.weight", "as", ".stage_2_bottleneck_2.bn_reduce.num_batches_tracked", ".stage_1_bottleneck_2.conv_reduce.weight", ".stage_3_bottleneck_1.conv_expand.weight", ".stage_3_bottleneck_2.conv_reduce.weight", ".stage_2_bottleneck_0.bn_reduce.weight", ".stage_3_bottleneck_0.shortcut.shortcut_bn.running_mean", ".stage_1_bottleneck_0.bn_reduce.bias", ".stage_1_bottleneck_2.bn_reduce.running_mean", ".stage_2_bottleneck_1.bn.running_mean", ".stage_1_bottleneck_0.shortcut.shortcut_bn.bias", ".stage_3_bottleneck_0.bn_reduce.running_var", "m_batches_tracked", ".stage_1_bottleneck_0.bn_expand.bias", ".stage_1_bottleneck_2.bn_expand.running_mean", ".stage_3_bottleneck_0.bn_expand.running_var", ".stage_2_bottleneck_0.conv_expand.weight", ".stage_2_bottleneck_0.bn.running_var", ".stage_3_bottleneck_1.bn_expand.weight", ".stage_1_bottleneck_1.bn.running_mean", ".stage_3_bottleneck_2.bn.running_mean", ".stage_3_bottleneck_2.bn_expand.running_mean", ".stage_1_bottleneck_0.conv_conv.weight", ".stage_3_bottleneck_1.bn_expand.running_mean", ".stage_2_bottleneck_0.conv_reduce.weight", ".stage_2_bottleneck_1.bn_reduce.bias", ".stage_1_bottleneck_0.bn_reduce.running_mean", ".stage_1_bottleneck_2.bn_reduce.running_var", ".stage_1_bottleneck_0.shortcut.shortcut_bn.num_batches_tracked", ".stage_1_bottleneck_2.bn_reduce.num_batches_tracked", ".stage_1_bottleneck_1.bn_reduce.running_mean", ".stage_3_bottleneck_1.bn_expand.running_var", ".stage_2_bottleneck_2.bn_reduce.running_mean", ".stage_3_bottleneck_0.shortcut.shortcut_bn.running_var", ".stage_3_bottleneck_2.bn_reduce.running_mean", "nning_var", ".stage_3_bottleneck_1.bn_reduce.weight", ".stage_3_bottleneck_2.bn_reduce.running_var", ".stage_2_bottleneck_0.shortcut.shortcut_conv.weight", ".stage_1_bottleneck_0.bn_expand.running_var", ".stage_2_bottleneck_0.shortcut.shortcut_bn.running_var", ".stage_3_bottleneck_0.bn_reduce.bias", ".stage_1_bottleneck_1.conv_conv.weight", ".stage_1_bottleneck_1.bn_reduce.bias", ".stage_3_bottleneck_1.bn.running_mean". 
    
    Process finished with exit code 1
    
    
    opened by ma3252788 1
  • sizes do not match

    sizes do not match

    ~/ResNeXt.pytorch0$ python test.py ~/DATASETS/cifar.python cifar10 --ngpu 1 --load ./snapshots/model.pytorch --test_bs 128 Files already downloaded and verified Files already downloaded and verified While copying the parameter named stage_1.stage_1_bottleneck_0.conv_reduce.weight, whose dimensions in the model are torch.Size([32, 64, 1, 1]) and whose dimensions in the checkpoint are torch.Size([512, 64, 1, 1]), ... Traceback (most recent call last): File "test.py", line 114, in test() File "test.py", line 79, in test net.load_state_dict(loaded_state_dict) File "/home/engineer/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 360, in load_state_dict own_state[name].copy_(param) RuntimeError: invalid argument 2: sizes do not match at /opt/conda/conda-bld/pytorch_1503970438496/work/torch/lib/THC/generic/THCTensorCopy.c:95

    please look into this issue, i am using pytorch 0.2.0. thanks

    opened by ZubairKhan001 1
  • Add test script and update readme.md

    Add test script and update readme.md

    I used this repository, but I didn't find test script.

    So, I refer to your train script for building test script and make PR.

    I did train and test on cifar 100 and 4 gpus.

    Regards

    • Result Files already downloaded and verified {'load': './snapshots/model.pytorch', 'test_loss': 0.7249295707744888, 'log': './', 'widen_factor': 4, 'data_path': '/home/appleholic/DATASETS/cifar.python', 'batch_size': 128, 'dataset': 'cifar100', 'depth': 29, 'ngpu': 4, 'prefetch': 2, 'test': False, 'cardinality': 8, 'test_bs': 128, 'test_accuracy': 0.8235}
    opened by AppleHolic 1
  • The structure problem

    The structure problem

    self.stage_1 = self.block('stage_1', self.stages[0], self.stages[1], 1) self.stage_2 = self.block('stage_2', self.stages[1], self.stages[2], 2) self.stage_3 = self.block('stage_3', self.stages[2], self.stages[3], 2) self.classifier = nn.Linear(self.stages[3], nlabels) . . . for bottleneck in range(self.block_depth): name_ = '%s_bottleneck_%d' % (name, bottleneck) if bottleneck == 0: block.add_module(name_, ResNeXtBottleneck(in_channels, out_channels, pool_stride, self.cardinality, self.base_width, self.widen_factor)) else: block.add_module(name_, ResNeXtBottleneck(out_channels, out_channels, 1, self.cardinality, self.base_width, self.widen_factor)) The structure of net is strange I see the Lua source code, it seems that there should have a maxpooling before stage_1? And the source code use the resnet structure to build the resneXt, but in your code, you use the same block number in every stage, but the resnet use four layers and use different block number in every layer, and there only have three stage, so is this the mistake?

    opened by Snowball0823 0
  • cannot run inference mismatch sizes

    cannot run inference mismatch sizes

    Hi, I was trying to run inference on the trained model using the test.py script but first there's an error on ordered dict iteritems() method which should be chnaged into items() and the other thing is that there are a lot of mismatches when loading the weighst into the model. Here's a screenshot:

    image

    Any ideas how to resolve those?

    opened by kirk86 2
  • Is the D right ?

    Is the D right ?

    https://github.com/prlz77/ResNeXt.pytorch/blob/48c19fba72a0d3971ba9edd6c4e61f860c3df519/models/model.py#L39

    Hi, This may be a stupid question. I did not read the original paper, but i think the channels of the conv layer with stride 3 should be less than that with stride 1, to reduce the computational complexity.

    I print the channels after line 39:

    print(widen_factor, in_channels, D, out_channels)

    and the output: 4 64 512 256 4 256 512 256 4 256 512 256 4 256 1024 512 4 512 1024 512 4 512 1024 512 4 512 2048 1024 4 1024 2048 1024 4 1024 2048 1024

    Is that right? thanks for answer

    opened by pppLang 6
  • Sublinear speed-up with dataparallel

    Sublinear speed-up with dataparallel

    With default arguments apart from cardinality (set to 16), I get:

    On 1 1080 ti with minibatch size 20: ~9 minutes per epoch. Using dataparallel across 4 1080 ti's with minibatch size 128: ~4.5 minutes per epoch.

    Perfect linear scaling would give you 2.25 minutes per epoch. Any idea what's going on here/how to get better scaling?

    opened by grey-area 1
  • GPU memory usage during training

    GPU memory usage during training

    It seems to me that each image uses ~5GB of GPU memory (ResNeXt-152), making it only possible to train with 2 images per GPU (TITAN X). Is that normal? I would appreciate if someone could be able to point out where I can start debugging for this?

    opened by realwecan 1
  • Questions about the performances.

    Questions about the performances.

    Hi,

    May I ask your final performance, the curves are a little confusing. I also implement a different version (https://github.com/D-X-Y/ResNeXt), my results are a little bit lower than the official code, about 0.2 for cifar10 and 1.0 for cifar100. I really want to what causes the differences.

    And I also try training resnet20,32,44,56 , I'm pretty sure the model archieteture is the same as the official code but even obtain a much lower accuracy.

    Would you mind to give me some suggestions?

    opened by D-X-Y 23
Owner
Pau Rodriguez
Pau Rodriguez
This code reproduces the results of the paper, "Measuring Data Leakage in Machine-Learning Models with Fisher Information"

Fisher Information Loss This repository contains code that can be used to reproduce the experimental results presented in the paper: Awni Hannun, Chua

Facebook Research 43 Dec 30, 2022
PyTorch implementation of the R2Plus1D convolution based ResNet architecture described in the paper "A Closer Look at Spatiotemporal Convolutions for Action Recognition"

R2Plus1D-PyTorch PyTorch implementation of the R2Plus1D convolution based ResNet architecture described in the paper "A Closer Look at Spatiotemporal

Irhum Shafkat 342 Dec 16, 2022
PyTorch implementation of MoCo v3 for self-supervised ResNet and ViT.

MoCo v3 for Self-supervised ResNet and ViT Introduction This is a PyTorch implementation of MoCo v3 for self-supervised ResNet and ViT. The original M

Facebook Research 887 Jan 8, 2023
Base pretrained models and datasets in pytorch (MNIST, SVHN, CIFAR10, CIFAR100, STL10, AlexNet, VGG16, VGG19, ResNet, Inception, SqueezeNet)

This is a playground for pytorch beginners, which contains predefined models on popular dataset. Currently we support mnist, svhn cifar10, cifar100 st

Aaron Chen 2.4k Dec 28, 2022
DeepLab resnet v2 model in pytorch

pytorch-deeplab-resnet DeepLab resnet v2 model implementation in pytorch. The architecture of deepLab-ResNet has been replicated exactly as it is from

Isht Dwivedi 601 Dec 22, 2022
3D ResNet Video Classification accelerated by TensorRT

Activity Recognition TensorRT Perform video classification using 3D ResNets trained on Kinetics-400 dataset and accelerated with TensorRT P.S Click on

Akash James 39 Nov 21, 2022
Quickly comparing your image classification models with the state-of-the-art models (such as DenseNet, ResNet, ...)

Image Classification Project Killer in PyTorch This repo is designed for those who want to start their experiments two days before the deadline and ki

null 349 Dec 8, 2022
Pretrained models for Jax/Flax: StyleGAN2, GPT2, VGG, ResNet.

Pretrained models for Jax/Flax: StyleGAN2, GPT2, VGG, ResNet.

Matthias Wright 169 Dec 26, 2022
improvement of CLIP features over the traditional resnet features on the visual question answering, image captioning, navigation and visual entailment tasks.

CLIP-ViL In our paper "How Much Can CLIP Benefit Vision-and-Language Tasks?", we show the improvement of CLIP features over the traditional resnet fea

null 310 Dec 28, 2022
Reproduce ResNet-v2(Identity Mappings in Deep Residual Networks) with MXNet

Reproduce ResNet-v2 using MXNet Requirements Install MXNet on a machine with CUDA GPU, and it's better also installed with cuDNN v5 Please fix the ran

Wei Wu 531 Dec 4, 2022
NFT-Price-Prediction-CNN - Using visual feature extraction, prices of NFTs are predicted via CNN (Alexnet and Resnet) architectures.

NFT-Price-Prediction-CNN - Using visual feature extraction, prices of NFTs are predicted via CNN (Alexnet and Resnet) architectures.

null 5 Nov 3, 2022
In this project we use both Resnet and Self-attention layer for cat, dog and flower classification.

cdf_att_classification classes = {0: 'cat', 1: 'dog', 2: 'flower'} In this project we use both Resnet and Self-attention layer for cdf-Classification.

null 3 Nov 23, 2022
Pretrained models for Jax/Haiku; MobileNet, ResNet, VGG, Xception.

Pre-trained image classification models for Jax/Haiku Jax/Haiku Applications are deep learning models that are made available alongside pre-trained we

Alper Baris CELIK 14 Dec 20, 2022
An essential implementation of BYOL in PyTorch + PyTorch Lightning

Essential BYOL A simple and complete implementation of Bootstrap your own latent: A new approach to self-supervised Learning in PyTorch + PyTorch Ligh

Enrico Fini 48 Sep 27, 2022
RealFormer-Pytorch Implementation of RealFormer using pytorch

RealFormer-Pytorch Implementation of RealFormer using pytorch. Includes comparison with classical Transformer on image classification task (ViT) wrt C

Simo Ryu 90 Dec 8, 2022
Generic template to bootstrap your PyTorch project with PyTorch Lightning, Hydra, W&B, and DVC.

NN Template Generic template to bootstrap your PyTorch project. Click on Use this Template and avoid writing boilerplate code for: PyTorch Lightning,

Luca Moschella 520 Dec 30, 2022
A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch

This repository holds NVIDIA-maintained utilities to streamline mixed precision and distributed training in Pytorch. Some of the code here will be included in upstream Pytorch eventually. The intention of Apex is to make up-to-date utilities available to users as quickly as possible.

NVIDIA Corporation 6.9k Jan 3, 2023
Objective of the repository is to learn and build machine learning models using Pytorch. 30DaysofML Using Pytorch

30 Days Of Machine Learning Using Pytorch Objective of the repository is to learn and build machine learning models using Pytorch. List of Algorithms

Mayur 119 Nov 24, 2022
Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pytorch Lightning 1.4k Jan 1, 2023