Giter Club home page Giter Club logo

shufflenet's Introduction

ShuffleNet in PyTorch

An implementation of ShuffleNet in PyTorch. ShuffleNet is an efficient convolutional neural network architecture for mobile devices. According to the paper, it outperforms Google's MobileNet by a small percentage.

What is ShuffleNet?

In one sentence, ShuffleNet is a ResNet-like model that uses residual blocks (called ShuffleUnits), with the main innovation being the use of pointwise, or 1x1, group convolutions as opposed to normal pointwise convolutions.

Usage

Clone the repo:

git clone https://github.com/jaxony/ShuffleNet.git

Use the model defined in model.py:

from model import ShuffleNet

# running on MNIST
net = ShuffleNet(num_classes=10, in_channels=1)

Performance

Trained on ImageNet (using the PyTorch ImageNet example) with groups=3 and no channel multiplier. On the test set, got 62.2% top 1 and 84.2% top 5. Unfortunately, this isn't comparable to Table 5 of the paper, because they don't run a network with these settings, but it is somewhere between the network with groups=3 and half the number of channels (42.8% top 1) and the network with the same number of channels but groups=8 (32.4% top 1). The pretrained state dictionary can be found here, in the following format:

{
    'epoch': epoch + 1,
    'arch': args.arch,
    'state_dict': model.state_dict(),
    'best_prec1': best_prec1,
    'optimizer' : optimizer.state_dict()
}

Note: trained with the default ImageNet settings, which are actually different from the training regime described in the paper. Pending running again with those settings (and groups=8).

shufflenet's People

Contributors

gngdb avatar jaxony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shufflenet's Issues

Question about the out_channels

Hi,
May I ask you a question? When the stride of shuffle unit is 2, why should the out_channels minus the in_channels?
the code in ShuffleUnit:

# ensure output of concat has the same channels as 
# original output channels.
self.out_channels -= self.in_channels

Train/Test Speed

Dear @jaxony ,

Thanks for your work!

I am using this to train ShuffleNet on ImageNet. However, both training and testing speed looks very slow.

ShuffleNet at epoch 2:

Test: [190/196] Time 3.673 (3.323)      Loss 2.3073 (3.7287)    Prec@1 43.750 (24.235)  Prec@5 75.000 (47.801)

While for AlexNet at epoch 2:

Test: [190/196] Time 0.672 (0.558)      Loss 3.7238 (4.3975)    Prec@1 28.125 (15.122)  Prec@5 50.391 (35.214)

ShuffleNet is about 6 times slower than AlexNet. Have you noticed this on MNIST?

Thanks!
Kun

ImageNet result

I noticed your imagenet result is 62.2% (top1), can you share your training log for me or more detail training setting?

When group=8, input channels cannot be divided by group number

Hi, when I run your code when group = 8, the error occurs that ValueError: in_channels must be divisible by groups.
According to the paper, I think there is no problem with your implementation. Do you have tested your code using group = 8?
By the way, there is the same problem when I tried to build ShuffleNet0.5x using scale=0.5.
To reproduce the issue, just modify groups=3 to groups=8 here: https://github.com/jaxony/ShuffleNet/blob/master/tests.py#L104

maybe a mistake

in file model.py , your function conv3x3() is a simple 2d convolution , but I found it should be depthwise conv according to the paper , the computation cost is totally different

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.